I thought that this bug report would be about the behaviour of which if PATH is unset, but this is not true.
A clean fix for this unfilled bug would require “getconf PATH” (getconf is in libc6-bin) to return the PATH bash and dash use, and ideally the other shells to adapt. * Justin Pryzby [2005-02-14 15:49 -0500]: > On Mon, Feb 14, 2005 at 09:31:50PM +0100, Thomas Hood wrote: > > On Sun, 2005-02-13 at 09:59 -0500, Justin Pryzby wrote: > > > On Sun, Feb 13, 2005 at 12:14:43PM +0100, Thomas Hood wrote: > > > > To canonicalize a path use "readlink -f". E.g., > > > As requested, it wouldn't follow symlink names. > > > > jdthood@thanatos:/tmp/w$ ls -l > > total 0 > > lrwxr-xr-x 1 jdthood jdthood 4 2005-02-14 21:30 usr -> /usr > > jdthood@thanatos:/tmp/w$ realpath -s //tmp//w//usr > > /tmp/w/usr > > > > > > You should be able to use something like: > > > > dpkg -S $(realpath -s $(which foo)) > I think sed also provides that functionality, as does Bash, I'm sure. > Since I don't want it to follow symlinks, I think the only > canonicalization needed is s+//+/+g. ELEMENT=${ELEMENT%/} would be sufficient to solve the original issue, i.e., remove the final slash of /usr/sbin/ if $PATH matches “*:/usr/sbin/:*”. Whether this is a good idea is an other question, and Clint already wrote that he doesn't think so. Carsten