mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-26 10:43:47 +08:00
wrealpath: Fail for file/something
This incorrectly allowed "file/something" if file existed (as a file), because it checked "afile". Fixes #5352.
This commit is contained in:
parent
b00b1af152
commit
ca1c499069
|
@ -421,7 +421,9 @@ maybe_t<wcstring> wrealpath(const wcstring &pathname) {
|
|||
} else {
|
||||
errno = 0;
|
||||
// Only call realpath() on the portion up to the last component.
|
||||
narrow_res = realpath(narrow_path.substr(0, pathsep_idx).c_str(), tmpbuff);
|
||||
// Be sure to include the last "/", so that the penultimate component is considered as a directory.
|
||||
// Otherwise "file/something" succeeds.
|
||||
narrow_res = realpath(narrow_path.substr(0, pathsep_idx + 1).c_str(), tmpbuff);
|
||||
|
||||
if (!narrow_res) return none();
|
||||
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
builtin realpath: /this/better/be/an/invalid/path: No such file or directory
|
||||
builtin realpath: .: No such file or directory
|
||||
builtin realpath: realpath.out/..: Not a directory
|
||||
|
|
|
@ -80,4 +80,7 @@ else
|
|||
echo "unexpected pwd-resolved-to-itself failure: $real_path != $PWD" >&2
|
||||
end
|
||||
|
||||
# Confirm that the penultimate component still needs to be a directory:
|
||||
builtin realpath realpath.out/..
|
||||
|
||||
exit 0
|
||||
|
|
Loading…
Reference in New Issue
Block a user