-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
whence -v
canonicalises paths improperly
#84
Comments
Related oddness:
Would expect:
libast has a |
whence -v
prints double initial backslashwhence -v
canonicalises paths improperly
This function should do path canonicalisation properly, as it uses Lines 571 to 589 in 01c25cb
|
The bug occurs here: ksh/src/cmd/ksh93/bltins/whence.c Lines 223 to 239 in db72f41
The root of the problem is that path_search() , called on line 223, prepends the present working directory (pwd) to any relative path, and the pwd always starts with a / . The *cp!='/' on line 234 then prevents path_fullname() from being called. So the fix is to remove that faulty check.
|
This bug was mediated by the fact that path_search() prefixes the present working directory to any relative path, but does not do any other canonicalisation. A faulty check then caused that path to be considered an absolute path and not in need of canonicalising, even if it contained '.' and '..' elements or double slashes. src/cmd/ksh93/bltins/whence.c: - Remove faulty check for initial '/' that prevented path_fullname() from ever being called. src/cmd/ksh93/tests/builtins.sh: - Add two 'whence -v' path canonicalisation tests. - Tweak other 'whence' tests for consistency. Fixes #84
Actually, I force-pushed this fix out again (sorry if that inconvenienced anyone) because it's still incomplete. Paths that are already absolute aren't canonicalised, e.g.:
The
But then that doesn't work when directly invoking commands (like A complete fix might be to check whether a path contains |
Commands:
(cd /; whence -v usr/bin/env)
Actual output:
Expected output:
Multiple slashes are usually ignored, but a double initial slash is permitted by POSIX to have a special meaning, and in fact has a special meaning on Cygwin (indicating a Windows UNC network path). So it should not be adding one for that reason alone. It's also ugly.
The text was updated successfully, but these errors were encountered: