Your message dated Thu, 22 Mar 2007 18:27:26 -0400
with message-id <[EMAIL PROTECTED]>
and subject line Bug#413473: /bin/which: fails with directories beginning with ~
has caused the attached Bug report to be marked as done.
This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.
(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere. Please contact me immediately.)
Debian bug tracking system administrator
(administrator, Debian Bugs database)
--- Begin Message ---
Package: debianutils
Version: 2.17
Severity: normal
Tags: patch
Hello,
An element like ~/bin in the PATH variable is not searched by which
because the test is [ -f "$ELEMENT/$PROGRAM" ] and there is no tilde
expansion within double quotes.
I propose the attached patch for replacing "~" by "$HOME" when an
element begins with "~/".
-- System Information:
Debian Release: 4.0
APT prefers testing
APT policy: (650, 'testing'), (500, 'stable')
Architecture: i386 (i686)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.18
Locale: [EMAIL PROTECTED], [EMAIL PROTECTED] (charmap=ISO-8859-15)
Versions of packages debianutils depends on:
ii coreutils 5.97-5.3 The GNU core utilities
ii libc6 2.3.6.ds1-11 GNU C Library: Shared libraries
ii mktemp 1.5-2 Makes unique filenames for tempora
debianutils recommends no packages.
-- no debconf information
--- /bin/which 2006-07-25 20:04:28.000000000 +0200
+++ ./which 2007-02-23 13:57:13.000000000 +0100
@@ -34,6 +34,9 @@
;;
*)
for ELEMENT in $PATH; do
+ case "$ELEMENT" in
+ "~"/*) ELEMENT="$HOME""${ELEMENT:1}" ;;
+ esac
if [ -z "$ELEMENT" ]; then
ELEMENT=.
fi
--- End Message ---
--- Begin Message ---
> Does this mean that tilde expansion is not POSIX-conformant ?
> I thought it was, since it is performed by dash.
It is. This is what POSIX says about tilde expansion:
| A "tilde-prefix" consists of an unquoted tilde character at the
| beginning of a word, followed by all of the characters preceding the
| first unquoted slash in the word, or all the characters in the word if
| there is no slash. In an assignment (see the Base Definitions volume of
| IEEE Std 1003.1-2001, Section 4.21, Variable Assignment), multiple
| tilde-prefixes can be used: at the beginning of the word (that is,
| following the equal sign of the assignment), following any unquoted
| colon, or both. A tilde-prefix in an assignment is terminated by the
| first unquoted colon or slash. If none of the characters in the
| tilde-prefix are quoted, the characters in the tilde-prefix following
| the tilde are treated as a possible login name from the user database. A
| portable login name cannot contain characters outside the set given in
| the description of the LOGNAME environment variable in the Base
| Definitions volume of IEEE Std 1003.1-2001, Section 8.3, Other
| Environment Variables. If the login name is null (that is, the
| tilde-prefix contains only the tilde), the tilde-prefix is replaced by
| the value of the variable HOME . If HOME is unset, the results are
| unspecified. Otherwise, the tilde-prefix shall be replaced by a pathname
| of the initial working directory associated with the login name obtained
| using the getpwnam() function as defined in the System Interfaces volume
| of IEEE Std 1003.1-2001. If the system does not recognize the login
| name, the results are undefined.
So this command
PATH=/usr/bin:/bin:~/bin
should set PATH to equal
/usr/bin:/bin:/home/clint/bin
but
PATH="~/bin:~:~rudolph/bin"
echo $PATH
should echo simply
~/bin:~:~rudolph/bin
and no further expansion thereof.
Hope this helps.
--- End Message ---