Why pwd does not accept long options like --physical?












10















When I display the manual for pwd command, it says that long options like --physical are supported



$ man pwd
PWD(1) User Commands PWD(1)

NAME
pwd - print name of current/working directory

SYNOPSIS
pwd [OPTION]...

DESCRIPTION
Print the full filename of the current working directory.

-L, --logical
use PWD from environment, even if it contains symlinks

-P, --physical
avoid all symlinks


However, it fails when I type the following



$ pwd --physical
-bash: pwd: --: invalid option
pwd: usage: pwd [-LP]


Why are long options not working for me?



I'm using RHEL 6.4. No alias for pwd is configured. Looks like it's standard pwd:



$ which pwd
/bin/pwd









share|improve this question




















  • 1





    The manual page is for a standalone utility which is not part of bash.

    – Thomas Dickey
    Jan 21 at 13:50






  • 7





    Use type instead of which, since which only shows commands, while type shows keywords, builtins, aliases, functions, and commands (and hashed command paths). For more details see Why not use “which”? What to use then?

    – wjandrea
    Jan 21 at 14:45






  • 1





    In my system man pwd has following note: your shell may have its own version of pwd, which usually supersedes the version described here. Please refer to your shell's documentation for details about the options it supports at the bottom of DESCRIPTION section.

    – Nykakin
    Jan 22 at 14:18


















10















When I display the manual for pwd command, it says that long options like --physical are supported



$ man pwd
PWD(1) User Commands PWD(1)

NAME
pwd - print name of current/working directory

SYNOPSIS
pwd [OPTION]...

DESCRIPTION
Print the full filename of the current working directory.

-L, --logical
use PWD from environment, even if it contains symlinks

-P, --physical
avoid all symlinks


However, it fails when I type the following



$ pwd --physical
-bash: pwd: --: invalid option
pwd: usage: pwd [-LP]


Why are long options not working for me?



I'm using RHEL 6.4. No alias for pwd is configured. Looks like it's standard pwd:



$ which pwd
/bin/pwd









share|improve this question




















  • 1





    The manual page is for a standalone utility which is not part of bash.

    – Thomas Dickey
    Jan 21 at 13:50






  • 7





    Use type instead of which, since which only shows commands, while type shows keywords, builtins, aliases, functions, and commands (and hashed command paths). For more details see Why not use “which”? What to use then?

    – wjandrea
    Jan 21 at 14:45






  • 1





    In my system man pwd has following note: your shell may have its own version of pwd, which usually supersedes the version described here. Please refer to your shell's documentation for details about the options it supports at the bottom of DESCRIPTION section.

    – Nykakin
    Jan 22 at 14:18
















10












10








10


3






When I display the manual for pwd command, it says that long options like --physical are supported



$ man pwd
PWD(1) User Commands PWD(1)

NAME
pwd - print name of current/working directory

SYNOPSIS
pwd [OPTION]...

DESCRIPTION
Print the full filename of the current working directory.

-L, --logical
use PWD from environment, even if it contains symlinks

-P, --physical
avoid all symlinks


However, it fails when I type the following



$ pwd --physical
-bash: pwd: --: invalid option
pwd: usage: pwd [-LP]


Why are long options not working for me?



I'm using RHEL 6.4. No alias for pwd is configured. Looks like it's standard pwd:



$ which pwd
/bin/pwd









share|improve this question
















When I display the manual for pwd command, it says that long options like --physical are supported



$ man pwd
PWD(1) User Commands PWD(1)

NAME
pwd - print name of current/working directory

SYNOPSIS
pwd [OPTION]...

DESCRIPTION
Print the full filename of the current working directory.

-L, --logical
use PWD from environment, even if it contains symlinks

-P, --physical
avoid all symlinks


However, it fails when I type the following



$ pwd --physical
-bash: pwd: --: invalid option
pwd: usage: pwd [-LP]


Why are long options not working for me?



I'm using RHEL 6.4. No alias for pwd is configured. Looks like it's standard pwd:



$ which pwd
/bin/pwd






bash rhel pwd






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 21 at 15:13









wjandrea

478413




478413










asked Jan 21 at 13:47









Michal KordasMichal Kordas

1668




1668








  • 1





    The manual page is for a standalone utility which is not part of bash.

    – Thomas Dickey
    Jan 21 at 13:50






  • 7





    Use type instead of which, since which only shows commands, while type shows keywords, builtins, aliases, functions, and commands (and hashed command paths). For more details see Why not use “which”? What to use then?

    – wjandrea
    Jan 21 at 14:45






  • 1





    In my system man pwd has following note: your shell may have its own version of pwd, which usually supersedes the version described here. Please refer to your shell's documentation for details about the options it supports at the bottom of DESCRIPTION section.

    – Nykakin
    Jan 22 at 14:18
















  • 1





    The manual page is for a standalone utility which is not part of bash.

    – Thomas Dickey
    Jan 21 at 13:50






  • 7





    Use type instead of which, since which only shows commands, while type shows keywords, builtins, aliases, functions, and commands (and hashed command paths). For more details see Why not use “which”? What to use then?

    – wjandrea
    Jan 21 at 14:45






  • 1





    In my system man pwd has following note: your shell may have its own version of pwd, which usually supersedes the version described here. Please refer to your shell's documentation for details about the options it supports at the bottom of DESCRIPTION section.

    – Nykakin
    Jan 22 at 14:18










1




1





The manual page is for a standalone utility which is not part of bash.

– Thomas Dickey
Jan 21 at 13:50





The manual page is for a standalone utility which is not part of bash.

– Thomas Dickey
Jan 21 at 13:50




7




7





Use type instead of which, since which only shows commands, while type shows keywords, builtins, aliases, functions, and commands (and hashed command paths). For more details see Why not use “which”? What to use then?

– wjandrea
Jan 21 at 14:45





Use type instead of which, since which only shows commands, while type shows keywords, builtins, aliases, functions, and commands (and hashed command paths). For more details see Why not use “which”? What to use then?

– wjandrea
Jan 21 at 14:45




1




1





In my system man pwd has following note: your shell may have its own version of pwd, which usually supersedes the version described here. Please refer to your shell's documentation for details about the options it supports at the bottom of DESCRIPTION section.

– Nykakin
Jan 22 at 14:18







In my system man pwd has following note: your shell may have its own version of pwd, which usually supersedes the version described here. Please refer to your shell's documentation for details about the options it supports at the bottom of DESCRIPTION section.

– Nykakin
Jan 22 at 14:18












2 Answers
2






active

oldest

votes


















26














bash has a built-in command pwd which is what you are using when you simply type pwd into your shell.



To get the pwd as described by the manpage, you need force use of the external command. You can do this by specifying the full path to the executable (/bin/pwd in your case) or by prepending env before the line: env pwd, which starts the env command which can be used to add settings to the environment (but which is not done here) and then env starts the command specified. As env doesn't have a builtin pwd, the "real" /bin/pwd is executed.



The advantage of the builtin pwd in bash is that bash keeps track of the current directory, so getting the value is at zero cost, whereas the external command needs to search up through the filesystem to determine the path, which is much more IO intensive.






share|improve this answer



















  • 4





    That's not how the external command actually works. unix.stackexchange.com/a/413225/5132

    – JdeBP
    Jan 21 at 16:59











  • BTW: You can also disable the shell builtin (at least in bash) by enable -n pwd

    – derobert
    Jan 21 at 20:18











  • @JdeBP It used to be last time I looked (a long time ago :-) ); and whereas it now uses the getcwd() system call, the kernel still traverses the filesystem, which is easier to do in kernel space due to access to relevant data structures, As the linked answer states: "However, note that even on FreeBSD and those other operating systems the kernel does not keep track of the working directory with a string."

    – wurtel
    Jan 22 at 9:03



















11














That manpage documents /bin/pwd, but when you run pwd you’re using the shell built-in; see the output of



type pwd


Your shell’s built-in pwd doesn’t support long options (see your shell’s documentation; since you’re using Bash, help pwd will provide a summary).






share|improve this answer

























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "106"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f495790%2fwhy-pwd-does-not-accept-long-options-like-physical%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    26














    bash has a built-in command pwd which is what you are using when you simply type pwd into your shell.



    To get the pwd as described by the manpage, you need force use of the external command. You can do this by specifying the full path to the executable (/bin/pwd in your case) or by prepending env before the line: env pwd, which starts the env command which can be used to add settings to the environment (but which is not done here) and then env starts the command specified. As env doesn't have a builtin pwd, the "real" /bin/pwd is executed.



    The advantage of the builtin pwd in bash is that bash keeps track of the current directory, so getting the value is at zero cost, whereas the external command needs to search up through the filesystem to determine the path, which is much more IO intensive.






    share|improve this answer



















    • 4





      That's not how the external command actually works. unix.stackexchange.com/a/413225/5132

      – JdeBP
      Jan 21 at 16:59











    • BTW: You can also disable the shell builtin (at least in bash) by enable -n pwd

      – derobert
      Jan 21 at 20:18











    • @JdeBP It used to be last time I looked (a long time ago :-) ); and whereas it now uses the getcwd() system call, the kernel still traverses the filesystem, which is easier to do in kernel space due to access to relevant data structures, As the linked answer states: "However, note that even on FreeBSD and those other operating systems the kernel does not keep track of the working directory with a string."

      – wurtel
      Jan 22 at 9:03
















    26














    bash has a built-in command pwd which is what you are using when you simply type pwd into your shell.



    To get the pwd as described by the manpage, you need force use of the external command. You can do this by specifying the full path to the executable (/bin/pwd in your case) or by prepending env before the line: env pwd, which starts the env command which can be used to add settings to the environment (but which is not done here) and then env starts the command specified. As env doesn't have a builtin pwd, the "real" /bin/pwd is executed.



    The advantage of the builtin pwd in bash is that bash keeps track of the current directory, so getting the value is at zero cost, whereas the external command needs to search up through the filesystem to determine the path, which is much more IO intensive.






    share|improve this answer



















    • 4





      That's not how the external command actually works. unix.stackexchange.com/a/413225/5132

      – JdeBP
      Jan 21 at 16:59











    • BTW: You can also disable the shell builtin (at least in bash) by enable -n pwd

      – derobert
      Jan 21 at 20:18











    • @JdeBP It used to be last time I looked (a long time ago :-) ); and whereas it now uses the getcwd() system call, the kernel still traverses the filesystem, which is easier to do in kernel space due to access to relevant data structures, As the linked answer states: "However, note that even on FreeBSD and those other operating systems the kernel does not keep track of the working directory with a string."

      – wurtel
      Jan 22 at 9:03














    26












    26








    26







    bash has a built-in command pwd which is what you are using when you simply type pwd into your shell.



    To get the pwd as described by the manpage, you need force use of the external command. You can do this by specifying the full path to the executable (/bin/pwd in your case) or by prepending env before the line: env pwd, which starts the env command which can be used to add settings to the environment (but which is not done here) and then env starts the command specified. As env doesn't have a builtin pwd, the "real" /bin/pwd is executed.



    The advantage of the builtin pwd in bash is that bash keeps track of the current directory, so getting the value is at zero cost, whereas the external command needs to search up through the filesystem to determine the path, which is much more IO intensive.






    share|improve this answer













    bash has a built-in command pwd which is what you are using when you simply type pwd into your shell.



    To get the pwd as described by the manpage, you need force use of the external command. You can do this by specifying the full path to the executable (/bin/pwd in your case) or by prepending env before the line: env pwd, which starts the env command which can be used to add settings to the environment (but which is not done here) and then env starts the command specified. As env doesn't have a builtin pwd, the "real" /bin/pwd is executed.



    The advantage of the builtin pwd in bash is that bash keeps track of the current directory, so getting the value is at zero cost, whereas the external command needs to search up through the filesystem to determine the path, which is much more IO intensive.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Jan 21 at 13:52









    wurtelwurtel

    10.4k11526




    10.4k11526








    • 4





      That's not how the external command actually works. unix.stackexchange.com/a/413225/5132

      – JdeBP
      Jan 21 at 16:59











    • BTW: You can also disable the shell builtin (at least in bash) by enable -n pwd

      – derobert
      Jan 21 at 20:18











    • @JdeBP It used to be last time I looked (a long time ago :-) ); and whereas it now uses the getcwd() system call, the kernel still traverses the filesystem, which is easier to do in kernel space due to access to relevant data structures, As the linked answer states: "However, note that even on FreeBSD and those other operating systems the kernel does not keep track of the working directory with a string."

      – wurtel
      Jan 22 at 9:03














    • 4





      That's not how the external command actually works. unix.stackexchange.com/a/413225/5132

      – JdeBP
      Jan 21 at 16:59











    • BTW: You can also disable the shell builtin (at least in bash) by enable -n pwd

      – derobert
      Jan 21 at 20:18











    • @JdeBP It used to be last time I looked (a long time ago :-) ); and whereas it now uses the getcwd() system call, the kernel still traverses the filesystem, which is easier to do in kernel space due to access to relevant data structures, As the linked answer states: "However, note that even on FreeBSD and those other operating systems the kernel does not keep track of the working directory with a string."

      – wurtel
      Jan 22 at 9:03








    4




    4





    That's not how the external command actually works. unix.stackexchange.com/a/413225/5132

    – JdeBP
    Jan 21 at 16:59





    That's not how the external command actually works. unix.stackexchange.com/a/413225/5132

    – JdeBP
    Jan 21 at 16:59













    BTW: You can also disable the shell builtin (at least in bash) by enable -n pwd

    – derobert
    Jan 21 at 20:18





    BTW: You can also disable the shell builtin (at least in bash) by enable -n pwd

    – derobert
    Jan 21 at 20:18













    @JdeBP It used to be last time I looked (a long time ago :-) ); and whereas it now uses the getcwd() system call, the kernel still traverses the filesystem, which is easier to do in kernel space due to access to relevant data structures, As the linked answer states: "However, note that even on FreeBSD and those other operating systems the kernel does not keep track of the working directory with a string."

    – wurtel
    Jan 22 at 9:03





    @JdeBP It used to be last time I looked (a long time ago :-) ); and whereas it now uses the getcwd() system call, the kernel still traverses the filesystem, which is easier to do in kernel space due to access to relevant data structures, As the linked answer states: "However, note that even on FreeBSD and those other operating systems the kernel does not keep track of the working directory with a string."

    – wurtel
    Jan 22 at 9:03













    11














    That manpage documents /bin/pwd, but when you run pwd you’re using the shell built-in; see the output of



    type pwd


    Your shell’s built-in pwd doesn’t support long options (see your shell’s documentation; since you’re using Bash, help pwd will provide a summary).






    share|improve this answer






























      11














      That manpage documents /bin/pwd, but when you run pwd you’re using the shell built-in; see the output of



      type pwd


      Your shell’s built-in pwd doesn’t support long options (see your shell’s documentation; since you’re using Bash, help pwd will provide a summary).






      share|improve this answer




























        11












        11








        11







        That manpage documents /bin/pwd, but when you run pwd you’re using the shell built-in; see the output of



        type pwd


        Your shell’s built-in pwd doesn’t support long options (see your shell’s documentation; since you’re using Bash, help pwd will provide a summary).






        share|improve this answer















        That manpage documents /bin/pwd, but when you run pwd you’re using the shell built-in; see the output of



        type pwd


        Your shell’s built-in pwd doesn’t support long options (see your shell’s documentation; since you’re using Bash, help pwd will provide a summary).







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Jan 21 at 14:56

























        answered Jan 21 at 13:50









        Stephen KittStephen Kitt

        168k24379457




        168k24379457






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f495790%2fwhy-pwd-does-not-accept-long-options-like-physical%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            An IMO inspired problem

            Management

            Investment