En la mayoría de las conchas, incluida bash, pwd
hay una concha incorporada:
$ type -a pwd
pwd is a shell builtin
pwd is /bin/pwd
Si lo usa /bin/pwd
, debe usar la -L
opción para obtener el mismo resultado que el incorporado pwd
:
$ ln -s . test
$ cd test && pwd
/home/cuonglm/test
$ /bin/pwd
/home/cuonglm
$ /bin/pwd -L
/home/cuonglm/test
Por defecto, /bin/pwd
ignora los enlaces simbólicos e imprime el directorio real.
De info pwd
:
`-L'
`--logical'
If the contents of the environment variable `PWD' provide an
absolute name of the current directory with no `.' or `..'
components, but possibly with symbolic links, then output those
contents. Otherwise, fall back to default `-P' handling.
`-P'
`--physical'
Print a fully resolved name for the current directory. That is,
all components of the printed name will be actual directory
names--none will be symbolic links.
La función integrada pwd
incluye el enlace simbólico de forma predeterminada, excepto que -P
se utiliza esa opción o que la -o physical
configuración interna está habilitada.
De man bash
:
pwd [-LP]
Print the absolute pathname of the current working directory.
The pathname printed contains no symbolic links if the -P option
is supplied or the -o physical option to the set builtin command
is enabled. If the -L option is used, the pathname printed may
contain symbolic links. The return status is 0 unless an error
occurs while reading the name of the current directory or an
invalid option is supplied.