Make tests usable with path with spaces
This is somewhat subtle:
The #RUN line in a littlecheck file will be run by a posix shell,
which means the substitutions will also be mangled by it.
Now, we *have* shell-quoted them, but unfortunately what we need is to
quote them for inside a pre-existing layer of quotes, e.g.
# RUN: fish -C 'set -g fish %fish'
here, %fish can't be replaced with `'path with spaces/fish'`, because
that ends up as
# RUN: fish -C 'set -g fish 'path with spaces/fish''
which is just broken.
So instead, we pass it as a variable to that fish:
# RUN: fish=%fish fish...
In addition, we need to not mangle the arguments in our test_driver.
For that, because we insist on posix shell, which has only one array,
and we source a file, we *need* to stop having that file use
arguments.
Which is okay - test_env.sh could previously be used to start a test,
and now it no longer can because that is test_*driver*.sh's job.
For the interactive tests, it's slightly different:
pexpect.spawn(foo) is sensitive to shell metacharacters like space.
So we shell-quote it.
But if you pass any args to pexpect.spawn, it no longer uses a shell,
and so we cannot shell-quote it.
There could be a better way to fix this?
2024-12-27 20:54:43 +01:00
|
|
|
# RUN: fish=%fish %fish %s
|
2019-12-31 14:16:20 -08:00
|
|
|
|
|
|
|
|
set -g fish (realpath $fish)
|
|
|
|
|
|
2025-11-17 12:25:40 -08:00
|
|
|
cygwin_nosymlinks && set nosymlinks
|
|
|
|
|
|
2019-12-31 14:16:20 -08:00
|
|
|
# Store pwd to later go back before cleaning up
|
|
|
|
|
set -l oldpwd (pwd)
|
|
|
|
|
|
2019-10-17 21:15:43 +02:00
|
|
|
set -l tmp (mktemp -d)
|
|
|
|
|
cd $tmp
|
|
|
|
|
# resolve CDPATH (issue 6220)
|
|
|
|
|
begin
|
|
|
|
|
mkdir -p x
|
|
|
|
|
# CHECK: /{{.*}}/x
|
2019-12-31 14:16:20 -08:00
|
|
|
cd x
|
|
|
|
|
pwd
|
2019-10-17 21:15:43 +02:00
|
|
|
|
|
|
|
|
# CHECK: /{{.*}}/x
|
2019-12-31 14:16:20 -08:00
|
|
|
set -lx CDPATH ..
|
|
|
|
|
cd x
|
|
|
|
|
pwd
|
2019-10-17 21:15:43 +02:00
|
|
|
end
|
2019-12-31 14:16:20 -08:00
|
|
|
cd $oldpwd
|
2020-01-30 17:34:48 +01:00
|
|
|
rm -rf $tmp
|
2019-12-31 14:16:20 -08:00
|
|
|
|
|
|
|
|
# Create a test directory to store our stuff.
|
2020-01-25 12:59:18 -08:00
|
|
|
# macOS likes to return symlinks from (mktemp -d), make sure it does not.
|
|
|
|
|
set -l base (realpath (mktemp -d))
|
2025-11-17 12:25:40 -08:00
|
|
|
|
|
|
|
|
if not set -q nosymlinks
|
|
|
|
|
set real (realpath (mktemp -d))
|
|
|
|
|
set link $base/link
|
|
|
|
|
ln -s $real $link
|
|
|
|
|
cd $link
|
|
|
|
|
prevd
|
|
|
|
|
nextd
|
|
|
|
|
test "$PWD" = "$link" || echo "\$PWD != \$link:"\n "\$PWD: $PWD"\n "\$link: $link"\n
|
|
|
|
|
test (pwd) = "$link" || echo "(pwd) != \$link:"\n "\$PWD: "(pwd)\n "\$link: $link"\n
|
|
|
|
|
test (pwd -P) = "$real" || echo "(pwd -P) != \$real:"\n "\$PWD: $PWD"\n "\$real: $real"\n
|
|
|
|
|
test (pwd -P -L) = "$link" || echo "(pwd -P -L) != \$link:"\n "\$PWD: $PWD"\n "\$link: $link"\n
|
|
|
|
|
end
|
2019-12-31 14:16:20 -08:00
|
|
|
# Expect no output on success.
|
2026-04-02 13:44:53 -07:00
|
|
|
pwd abc
|
|
|
|
|
# CHECKERR: pwd: expected 0 arguments; got 1
|
|
|
|
|
|
2025-11-17 12:25:40 -08:00
|
|
|
if set -q nosymlinks
|
|
|
|
|
echo "pwd: realpath failed: No such file or directory" >&2
|
|
|
|
|
else
|
|
|
|
|
mkdir -p $base/pwd_real/subdir
|
|
|
|
|
ln -s $base/pwd_real $base/pwd_link
|
|
|
|
|
cd $base/pwd_link/subdir
|
|
|
|
|
rmdir $base/pwd_real/subdir $base/pwd_real
|
|
|
|
|
pwd -P
|
|
|
|
|
end
|
|
|
|
|
# CHECKERR: pwd: realpath failed: {{.+}}
|
2019-12-31 14:16:20 -08:00
|
|
|
|
2026-05-30 00:00:42 +08:00
|
|
|
if not set -q nosymlinks
|
|
|
|
|
mkdir $real/subdir
|
|
|
|
|
cd $link
|
|
|
|
|
test "$PWD" = "$link" || echo "Default cd should keep symlink:"\n "\$PWD: $PWD"\n "\$link: $link"\n
|
|
|
|
|
cd -P $link
|
|
|
|
|
test "$PWD" = "$real" || echo "cd -P should resolve symlink:"\n "\$PWD: $PWD"\n "\$real: $real"\n
|
|
|
|
|
cd $link/subdir
|
|
|
|
|
test "$PWD" = "$link/subdir" || echo "Logical cd should keep subdir symlink:"\n "\$PWD: $PWD"\n "\$link/subdir: $link/subdir"\n
|
|
|
|
|
cd -P ..
|
|
|
|
|
test "$PWD" = "$real" || echo "cd -P .. should use physical parent:"\n "\$PWD: $PWD"\n "\$real: $real"\n
|
|
|
|
|
cd $link/subdir
|
|
|
|
|
cd -L ..
|
|
|
|
|
test "$PWD" = "$link" || echo "cd -L .. should use logical parent:"\n "\$PWD: $PWD"\n "\$link: $link"\n
|
|
|
|
|
cd $base
|
|
|
|
|
end
|
2025-10-08 04:26:16 +09:00
|
|
|
|
2019-12-31 14:16:20 -08:00
|
|
|
# Create a symlink and verify logical completion.
|
|
|
|
|
# create directory $base/through/the/looking/glass
|
2025-11-17 12:25:40 -08:00
|
|
|
# symlink $base/somewhere/rabbithole -> $base/through/the/looking/glass
|
2019-12-31 14:16:20 -08:00
|
|
|
# verify that .. completions work
|
|
|
|
|
cd $base
|
|
|
|
|
mkdir -p $base/through/the/looking/glass
|
|
|
|
|
|
|
|
|
|
mkdir -p $base/somewhere
|
|
|
|
|
mkdir $base/somewhere/a1
|
|
|
|
|
mkdir $base/somewhere/a2
|
|
|
|
|
mkdir $base/somewhere/a3
|
|
|
|
|
touch $base/through/the/looking/b(seq 1 3)
|
|
|
|
|
mkdir $base/through/the/looking/d1
|
|
|
|
|
mkdir $base/through/the/looking/d2
|
|
|
|
|
mkdir $base/through/the/looking/d3
|
|
|
|
|
ln -s $base/through/the/looking/glass $base/somewhere/rabbithole
|
|
|
|
|
|
2025-11-17 12:25:40 -08:00
|
|
|
if set -q nosymlinks
|
|
|
|
|
# This is where we would be going if symlinks were working. This invalidates
|
|
|
|
|
# that particular test case, but now we can proceed with the tests
|
|
|
|
|
cd $base/through/the/looking/glass
|
|
|
|
|
else
|
|
|
|
|
cd $base/somewhere/rabbithole
|
|
|
|
|
end
|
2019-12-31 14:16:20 -08:00
|
|
|
echo "ls:"
|
|
|
|
|
complete -C'ls ../'
|
|
|
|
|
#CHECK: ls:
|
|
|
|
|
#CHECK: ../b1
|
|
|
|
|
#CHECK: ../b2
|
|
|
|
|
#CHECK: ../b3
|
|
|
|
|
#CHECK: ../d1/
|
|
|
|
|
#CHECK: ../d2/
|
|
|
|
|
#CHECK: ../d3/
|
|
|
|
|
#CHECK: ../glass/
|
|
|
|
|
|
2025-11-17 12:25:40 -08:00
|
|
|
if set -q nosymlinks
|
|
|
|
|
cd $base/somewhere/rabbithole
|
|
|
|
|
end
|
2019-12-31 14:16:20 -08:00
|
|
|
echo "cd:"
|
|
|
|
|
complete -C'cd ../'
|
|
|
|
|
#CHECK: cd:
|
|
|
|
|
#CHECK: ../a1/
|
|
|
|
|
#CHECK: ../a2/
|
|
|
|
|
#CHECK: ../a3/
|
|
|
|
|
#CHECK: ../rabbithole/
|
|
|
|
|
|
|
|
|
|
# PWD should be imported and respected by fish
|
|
|
|
|
cd $oldpwd
|
|
|
|
|
mkdir -p $base/realhome
|
|
|
|
|
ln -s $base/realhome $base/linkhome
|
|
|
|
|
cd $base/linkhome
|
|
|
|
|
set -l real_getcwd (pwd -P)
|
|
|
|
|
env HOME=$base/linkhome $fish -c 'echo PWD is $PWD'
|
2020-01-25 12:59:18 -08:00
|
|
|
#CHECK: PWD is {{.*}}/linkhome
|
2019-12-31 14:16:20 -08:00
|
|
|
|
|
|
|
|
# Do not inherit a virtual PWD that fails to resolve to getcwd (#5647)
|
|
|
|
|
env HOME=$base/linkhome PWD=/tmp $fish -c 'echo $PWD' | read output_pwd
|
|
|
|
|
test (realpath $output_pwd) = $real_getcwd
|
|
|
|
|
and echo "BogusPWD test 1 succeeded"
|
|
|
|
|
or echo "BogusPWD test 1 failed: $output_pwd vs $real_getcwd"
|
|
|
|
|
#CHECK: BogusPWD test 1 succeeded
|
|
|
|
|
|
|
|
|
|
env HOME=$base/linkhome PWD=/path/to/nowhere $fish -c 'echo $PWD' | read output_pwd
|
|
|
|
|
test (realpath $output_pwd) = $real_getcwd
|
|
|
|
|
and echo "BogusPWD test 2 succeeded"
|
|
|
|
|
or echo "BogusPWD test 2 failed: $output_pwd vs $real_getcwd"
|
|
|
|
|
#CHECK: BogusPWD test 2 succeeded
|
|
|
|
|
|
|
|
|
|
# $CDPATH
|
|
|
|
|
set -g CDPATH $base
|
|
|
|
|
cd linkhome
|
|
|
|
|
test $PWD = $base/linkhome; and echo Gone to linkhome via CDPATH
|
|
|
|
|
#CHECK: Gone to linkhome via CDPATH
|
|
|
|
|
|
|
|
|
|
set -g CDPATH /tmp
|
|
|
|
|
cd $base
|
|
|
|
|
test $PWD = $base; and echo Gone to base
|
|
|
|
|
#CHECK: Gone to base
|
|
|
|
|
|
|
|
|
|
cd linkhome
|
|
|
|
|
test $PWD = $base/linkhome; and echo Gone to linkhome via implicit . in CDPATH
|
|
|
|
|
#CHECK: Gone to linkhome via implicit . in CDPATH
|
|
|
|
|
|
|
|
|
|
set -g CDPATH ./
|
|
|
|
|
cd $base
|
|
|
|
|
test $PWD = $base; and echo No crash with ./ CDPATH
|
|
|
|
|
#CHECK: No crash with ./ CDPATH
|
|
|
|
|
|
|
|
|
|
# test for directories beginning with a hyphen
|
|
|
|
|
mkdir $base/-testdir
|
|
|
|
|
cd $base
|
|
|
|
|
cd -- -testdir
|
|
|
|
|
test $PWD = $base/-testdir
|
|
|
|
|
echo $status
|
|
|
|
|
#CHECK: 0
|
|
|
|
|
|
2020-12-28 22:40:30 +01:00
|
|
|
# test a few error cases - nonexistent directory
|
|
|
|
|
set -l old_cdpath $CDPATH
|
|
|
|
|
set -l old_path $PWD
|
|
|
|
|
cd nonexistent
|
|
|
|
|
#CHECKERR: cd: The directory 'nonexistent' does not exist
|
|
|
|
|
#CHECKERR: {{.*}}/cd.fish (line {{\d+}}):
|
|
|
|
|
#CHECKERR: builtin cd $argv
|
|
|
|
|
#CHECKERR: ^
|
|
|
|
|
#CHECKERR: in function 'cd' with arguments 'nonexistent'
|
|
|
|
|
#CHECKERR: called on line {{\d+}} of file {{.*}}/cd.fish
|
|
|
|
|
|
|
|
|
|
touch file
|
|
|
|
|
cd file
|
|
|
|
|
#CHECKERR: cd: 'file' is not a directory
|
|
|
|
|
#CHECKERR: {{.*}}/cd.fish (line {{\d+}}):
|
|
|
|
|
#CHECKERR: builtin cd $argv
|
|
|
|
|
#CHECKERR: ^
|
|
|
|
|
#CHECKERR: in function 'cd' with arguments 'file'
|
|
|
|
|
#CHECKERR: called on line {{\d+}} of file {{.*}}/cd.fish
|
|
|
|
|
|
|
|
|
|
# a directory that isn't executable
|
2025-11-17 12:25:40 -08:00
|
|
|
if cygwin_noacl ./
|
|
|
|
|
echo "cd: Permission denied: 'bad-perms'" >&2
|
|
|
|
|
echo "fake/cd.fish (line 123):" >&2
|
|
|
|
|
echo "builtin cd \$argv" >&2
|
|
|
|
|
echo "^" >&2
|
|
|
|
|
echo "in function 'cd' with arguments 'bad-perms'" >&2
|
|
|
|
|
echo "called on line 123 of file fake/cd.fish" >&2
|
|
|
|
|
else
|
|
|
|
|
mkdir bad-perms
|
|
|
|
|
chmod -x bad-perms
|
|
|
|
|
cd bad-perms
|
|
|
|
|
end
|
2020-12-28 22:40:30 +01:00
|
|
|
#CHECKERR: cd: Permission denied: 'bad-perms'
|
|
|
|
|
#CHECKERR: {{.*}}/cd.fish (line {{\d+}}):
|
|
|
|
|
#CHECKERR: builtin cd $argv
|
|
|
|
|
#CHECKERR: ^
|
|
|
|
|
#CHECKERR: in function 'cd' with arguments 'bad-perms'
|
|
|
|
|
#CHECKERR: called on line {{\d+}} of file {{.*}}/cd.fish
|
|
|
|
|
|
|
|
|
|
cd $old_path
|
|
|
|
|
mkdir -p cdpath-dir/bad-perms
|
|
|
|
|
mkdir -p cdpath-dir/nonexistent
|
|
|
|
|
mkdir -p cdpath-dir/file
|
|
|
|
|
set CDPATH $PWD/cdpath-dir $old_cdpath
|
|
|
|
|
|
2021-07-23 17:21:12 +02:00
|
|
|
# See that the completions also check the current directory
|
|
|
|
|
complete -C'cd ' | string match -q cdpath-dir/
|
|
|
|
|
and echo cdpath-dir is in
|
|
|
|
|
# CHECK: cdpath-dir is in
|
|
|
|
|
|
2020-12-28 22:40:30 +01:00
|
|
|
# A different directory with the same name that is first in $CDPATH works.
|
|
|
|
|
cd bad-perms
|
|
|
|
|
cd $old_path
|
|
|
|
|
cd nonexistent
|
|
|
|
|
cd $old_path
|
|
|
|
|
cd file
|
|
|
|
|
cd $old_path
|
|
|
|
|
|
|
|
|
|
# Even if the good dirs are later in $CDPATH most errors still aren't a problem
|
|
|
|
|
# - they just cause us to keep looking.
|
|
|
|
|
cd $old_path
|
|
|
|
|
set CDPATH $old_cdpath $PWD/cdpath-dir
|
|
|
|
|
cd nonexistent
|
|
|
|
|
cd $old_path
|
2025-11-17 12:25:40 -08:00
|
|
|
if cygwin_noacl ./
|
|
|
|
|
echo "cd: Permission denied: 'bad-perms'" >&2
|
|
|
|
|
echo "fake/cd.fish (line 123):" >&2
|
|
|
|
|
echo "builtin cd \$argv" >&2
|
|
|
|
|
echo "^" >&2
|
|
|
|
|
echo "in function 'cd' with arguments 'bad-perms'" >&2
|
|
|
|
|
echo "called on line 123 of file fake/cd.fish" >&2
|
|
|
|
|
else
|
|
|
|
|
cd bad-perms
|
|
|
|
|
end
|
2020-12-28 22:40:30 +01:00
|
|
|
# Permission errors are still a problem!
|
|
|
|
|
#CHECKERR: cd: Permission denied: 'bad-perms'
|
|
|
|
|
#CHECKERR: {{.*}}/cd.fish (line {{\d+}}):
|
|
|
|
|
#CHECKERR: builtin cd $argv
|
|
|
|
|
#CHECKERR: ^
|
|
|
|
|
#CHECKERR: in function 'cd' with arguments 'bad-perms'
|
|
|
|
|
#CHECKERR: called on line {{\d+}} of file {{.*}}/cd.fish
|
|
|
|
|
cd $old_path
|
|
|
|
|
cd file
|
|
|
|
|
cd $old_path
|
2019-12-31 14:16:20 -08:00
|
|
|
|
2024-07-28 16:40:14 +00:00
|
|
|
# Test that going up to the root directory using .. works
|
|
|
|
|
cd /(string split --no-empty -f 1 / (pwd))
|
|
|
|
|
cd ..
|
|
|
|
|
pwd
|
|
|
|
|
#CHECK: /
|
|
|
|
|
|
2019-12-31 14:16:20 -08:00
|
|
|
# cd back before removing the test directory again.
|
|
|
|
|
cd $oldpwd
|
|
|
|
|
rm -Rf $base
|
2020-12-28 22:40:30 +01:00
|
|
|
set -g CDPATH ./
|
2019-12-31 14:16:20 -08:00
|
|
|
|
|
|
|
|
# Verify that PWD on-variable events are sent
|
|
|
|
|
function __fish_test_changed_pwd --on-variable PWD
|
|
|
|
|
echo "Changed to $PWD"
|
|
|
|
|
end
|
|
|
|
|
cd /
|
|
|
|
|
functions --erase __fish_test_changed_pwd
|
|
|
|
|
#CHECK: Changed to /
|
|
|
|
|
|
|
|
|
|
# Verify that cds don't stomp on each other.
|
|
|
|
|
function __fish_test_thrash_cd
|
|
|
|
|
set -l dir (mktemp -d)
|
|
|
|
|
cd $dir
|
|
|
|
|
for i in (seq 50)
|
2026-03-13 17:50:04 +01:00
|
|
|
test (command pwd) = $dir
|
2019-12-31 14:16:20 -08:00
|
|
|
and test $PWD = $dir
|
|
|
|
|
or echo "cd test failed" 1>&2
|
|
|
|
|
sleep .002
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
__fish_test_thrash_cd |
|
2025-12-16 08:00:34 -08:00
|
|
|
__fish_test_thrash_cd |
|
|
|
|
|
__fish_test_thrash_cd |
|
|
|
|
|
__fish_test_thrash_cd |
|
|
|
|
|
__fish_test_thrash_cd
|
2021-07-17 19:00:35 +02:00
|
|
|
|
|
|
|
|
cd ""
|
|
|
|
|
# CHECKERR: cd: Empty directory '' does not exist
|
|
|
|
|
# CHECKERR: {{.*}}/cd.fish (line {{\d+}}):
|
|
|
|
|
# CHECKERR: builtin cd $argv
|
|
|
|
|
# CHECKERR: ^
|
|
|
|
|
# CHECKERR: in function 'cd' with arguments '""'
|
|
|
|
|
# CHECKERR: called on line {{\d+}} of file {{.*}}/cd.fish
|
|
|
|
|
echo $status
|
|
|
|
|
# CHECK: 1
|
2021-09-05 02:11:21 +02:00
|
|
|
|
2021-09-24 17:35:45 -07:00
|
|
|
cd (mktemp -d)
|
2025-11-17 12:25:40 -08:00
|
|
|
if set -q nosymlinks
|
|
|
|
|
echo "cd: 'fake/broken-symbolic-link' is a broken symbolic link to 'no/such/directory'" >&2
|
|
|
|
|
echo "fake/cd.fish (line 123):" >&2
|
|
|
|
|
echo "builtin cd \$argv" >&2
|
|
|
|
|
echo "^" >&2
|
|
|
|
|
echo "in function 'cd' with arguments 'broken-symbolic-link'" >&2
|
|
|
|
|
echo "called on line 123 of file fake/cd.fish" >&2
|
|
|
|
|
else
|
|
|
|
|
ln -s no/such/directory broken-symbolic-link
|
|
|
|
|
begin
|
|
|
|
|
set -lx CDPATH
|
|
|
|
|
cd broken-symbolic-link
|
|
|
|
|
end
|
2021-09-05 02:11:21 +02:00
|
|
|
end
|
|
|
|
|
# CHECKERR: cd: '{{.*}}/broken-symbolic-link' is a broken symbolic link to 'no/such/directory'
|
|
|
|
|
# CHECKERR: {{.*}}/cd.fish (line {{\d+}}):
|
|
|
|
|
# CHECKERR: builtin cd $argv
|
|
|
|
|
# CHECKERR: ^
|
|
|
|
|
# CHECKERR: in function 'cd' with arguments 'broken-symbolic-link'
|
|
|
|
|
# CHECKERR: called on line {{\d+}} of file {{.*}}/cd.fish
|
|
|
|
|
|
|
|
|
|
# Make sure that "broken symlink" is reported over "no such file or directory".
|
2025-11-17 12:25:40 -08:00
|
|
|
if set -q nosymlinks
|
|
|
|
|
echo "cd: 'fake/broken-symbolic-link' is a broken symbolic link to 'no/such/directory'" >&2
|
|
|
|
|
echo "fake/cd.fish (line 123):" >&2
|
|
|
|
|
echo "builtin cd \$argv" >&2
|
|
|
|
|
echo "^" >&2
|
|
|
|
|
echo "in function 'cd' with arguments 'broken-symbolic-link'" >&2
|
|
|
|
|
echo "called on line 123 of file fake/cd.fish" >&2
|
|
|
|
|
else
|
|
|
|
|
begin
|
|
|
|
|
set -lx CDPATH other
|
|
|
|
|
cd broken-symbolic-link
|
|
|
|
|
end
|
2021-09-05 02:11:21 +02:00
|
|
|
end
|
|
|
|
|
# CHECKERR: cd: '{{.*}}/broken-symbolic-link' is a broken symbolic link to 'no/such/directory'
|
|
|
|
|
# CHECKERR: {{.*}}/cd.fish (line {{\d+}}):
|
|
|
|
|
# CHECKERR: builtin cd $argv
|
|
|
|
|
# CHECKERR: ^
|
|
|
|
|
# CHECKERR: in function 'cd' with arguments 'broken-symbolic-link'
|
|
|
|
|
# CHECKERR: called on line {{\d+}} of file {{.*}}/cd.fish
|
2022-12-10 10:56:17 +01:00
|
|
|
|
|
|
|
|
begin
|
|
|
|
|
mkdir -p foo/bar/muf
|
|
|
|
|
set -lx CDPATH foo/bar
|
|
|
|
|
cd muf
|
|
|
|
|
echo $PWD | grep -q ^/ && echo '$PWD is absolute'
|
|
|
|
|
# CHECK: $PWD is absolute
|
|
|
|
|
cd ../../..
|
|
|
|
|
end
|
2023-01-16 10:05:01 +01:00
|
|
|
|
|
|
|
|
complete -C'cd .'
|
|
|
|
|
# CHECK: ./
|
2026-05-03 18:49:21 +08:00
|
|
|
# CHECK: ../
|
2024-04-11 18:13:39 +02:00
|
|
|
|
2024-05-11 12:48:40 -07:00
|
|
|
# Check that cd works with minimal permissions (issue #10432).
|
|
|
|
|
# This is first supported on macOS 12.
|
|
|
|
|
# `sysctl kern.osproductversion` emits something like:
|
|
|
|
|
# kern.osproductversion: 14.3.1
|
2024-05-30 12:08:13 -05:00
|
|
|
# Note that there is no kern.osproductversion under older OS X releases!
|
2024-08-15 17:34:00 +02:00
|
|
|
#
|
|
|
|
|
# NetBSD 10 does not support it.
|
2026-04-04 18:11:29 -07:00
|
|
|
# Cygwin/MSYS does not support it when using ACL. And without ACL, a directory
|
|
|
|
|
# cannot be made unreadable, making the test pointless. So either way, skip it
|
|
|
|
|
if test (uname) = NetBSD || __fish_is_cygwin || { test (uname) = Darwin && test (sysctl kern.osproductversion 2>/dev/null | string match -r \\d+; or echo 10) -lt 12 }
|
2024-05-11 12:48:40 -07:00
|
|
|
# Not supported. Satisfy the CHECKs below.
|
|
|
|
|
echo fake/a
|
|
|
|
|
echo fake/a/b
|
|
|
|
|
echo c
|
|
|
|
|
else
|
2024-04-11 18:13:39 +02:00
|
|
|
set -l oldpwd (pwd)
|
|
|
|
|
set -l tmp (mktemp -d)
|
|
|
|
|
cd $tmp
|
|
|
|
|
mkdir -p a/b/c
|
|
|
|
|
chmod -r a
|
|
|
|
|
|
2025-12-16 08:00:34 -08:00
|
|
|
cd a
|
|
|
|
|
pwd
|
2024-04-11 18:13:39 +02:00
|
|
|
# CHECK: {{.*}}/a
|
|
|
|
|
|
|
|
|
|
cd b
|
|
|
|
|
pwd
|
|
|
|
|
ls
|
|
|
|
|
# CHECK: {{.*}}/a/b
|
|
|
|
|
# CHECK: c
|
|
|
|
|
|
|
|
|
|
cd $oldpwd
|
|
|
|
|
chmod -R +rx $tmp # we must be able to list the directory to delete its children
|
|
|
|
|
rm -rf $tmp
|
|
|
|
|
end
|
2026-04-02 13:44:53 -07:00
|
|
|
|
|
|
|
|
HOME="" cd
|
|
|
|
|
# CHECKERR: cd: Could not find home directory
|
|
|
|
|
|
2025-11-17 12:25:40 -08:00
|
|
|
if set -q nosymlinks
|
|
|
|
|
echo "cd: Too many levels of symbolic links: 'loop1'" >&2
|
|
|
|
|
echo "fake/cd.fish (line 123):" >&2
|
|
|
|
|
echo "builtin cd \$argv" >&2
|
|
|
|
|
echo "^" >&2
|
|
|
|
|
echo "in function 'cd' with arguments 'loop1'" >&2
|
|
|
|
|
echo "called on line 123 of file fake/cd.fish" >&2
|
|
|
|
|
else
|
|
|
|
|
ln -s loop1 loop2
|
|
|
|
|
ln -s loop2 loop1
|
|
|
|
|
cd loop1
|
|
|
|
|
end
|
2026-04-02 13:44:53 -07:00
|
|
|
# CHECKERR: cd: Too many levels of symbolic links: 'loop1'
|
|
|
|
|
# CHECKERR: {{.*}}/cd.fish (line {{\d+}}):
|
|
|
|
|
# CHECKERR: builtin cd $argv
|
|
|
|
|
# CHECKERR: ^
|
|
|
|
|
# CHECKERR: in function 'cd' with arguments 'loop1'
|
|
|
|
|
# CHECKERR: called on line {{\d+}} of file {{.*}}/cd.fish
|
|
|
|
|
|
|
|
|
|
# According to https://en.wikipedia.org/wiki/Comparison_of_file_systems#Limits,
|
|
|
|
|
# the longest filename supported is with Reiser4 (3976 bytes)
|
|
|
|
|
cd (string repeat 4096 a)
|
|
|
|
|
# CHECKERR: cd: {{.+}}
|
|
|
|
|
# CHECKERR: cd: Unknown error trying to locate directory '{{.*}}'
|
|
|
|
|
# CHECKERR: {{.*}}/cd.fish (line {{\d+}}):
|
|
|
|
|
# CHECKERR: builtin cd $argv
|
|
|
|
|
# CHECKERR: ^
|
|
|
|
|
# CHECKERR: in function 'cd' with arguments '{{.*}}'
|
|
|
|
|
# CHECKERR: called on line {{\d+}} of file {{.*}}/cd.fish
|
2026-04-30 11:30:16 -07:00
|
|
|
|
|
|
|
|
# Ensures `cd` doesn't create `<pwd>+/+<dir>` internally, when pwd is `/`, i.e.
|
|
|
|
|
# results in `//<dir>`. This test will (hopefully) fail on platforms where such
|
|
|
|
|
# a path has a special meaning (e.g. Windows would fail trying to access a server
|
|
|
|
|
# named "bin")
|
|
|
|
|
cd /
|
|
|
|
|
cd bin
|