[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bug, i think? pwd --help and pwd --version don't work
From: |
Eric Blake |
Subject: |
Re: bug, i think? pwd --help and pwd --version don't work |
Date: |
Fri, 08 Apr 2005 16:26:23 +0000 |
> address@hidden ~]$ pwd --help
> bash: pwd: --: invalid option
> pwd: usage: pwd [-PL]
>
> address@hidden ~]$ which pwd
> /usr/local/bin/pwd
>
> Strange. Any idea what's going wrong?
Yes - which(1) is not required by POSIX, but it is a tcsh builtin that
corresponds to the POSIX-required type(1). Depending on whether type/which is
a program, an alias, or a shell-builtin, it reports different information -
only a shell builtin can report correct information about shell builtins and
aliases. In conclusion, your information about what pwd really is depends on
how you ask. On my system:
$ bash # where pwd is builtin, type is builtin, which is program
$ type pwd
pwd is a shell builtin
$ which pwd
/usr/bin/pwd
$ type which
which is hashed (/usr/bin/which)
$ which which
/usr/bin/which
$ type type
type is a shell builtin
$ which type
type: Command not found.
$ tcsh # where pwd is program, type is alias for which, which is builtin
# type pwd
/usr/bin/pwd
# \type pwd
type: Command not found.
# which pwd
/usr/bin/pwd
# type which
which: shell built-in command.
# which type
type: aliased to which
#
If you want the tcsh behavior of which inside of bash, then do something like
one of these two options:
$ alias which type
$ which()
{
type "$@"
}
--
Eric Blake