2019-01-03 22:17:20 +00:00
|
|
|
# Store pwd to later go back before cleaning up
|
|
|
|
set -l oldpwd (pwd)
|
2019-01-16 10:15:38 +00:00
|
|
|
# Create a test directory to store our stuff.
|
|
|
|
set -l base /tmp/cdcomp_test
|
|
|
|
rm -Rf $base
|
|
|
|
mkdir -p $base
|
2018-09-17 01:03:13 +00:00
|
|
|
logmsg cd symlink non-resolution
|
|
|
|
set real (mktemp -d)
|
2019-01-16 10:15:38 +00:00
|
|
|
set link $base/link
|
2018-09-17 01:03:13 +00:00
|
|
|
ln -s $real $link
|
|
|
|
cd $link
|
|
|
|
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
|
2018-11-03 20:30:55 +00:00
|
|
|
|
|
|
|
logmsg cd symlink completion
|
|
|
|
|
|
|
|
# Create a symlink and verify logical completion.
|
|
|
|
# create directory $base/through/the/looking/glass
|
|
|
|
# symlink $base/somewhere/teleport -> $base/through/the/looking/glass
|
|
|
|
# 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
|
|
|
|
|
|
|
|
cd $base/somewhere/rabbithole
|
|
|
|
echo "ls:"
|
|
|
|
complete -C'ls ../'
|
|
|
|
echo "cd:"
|
|
|
|
complete -C'cd ../'
|
2019-01-03 22:17:20 +00:00
|
|
|
|
2019-01-22 21:07:55 +00:00
|
|
|
logmsg Virtual PWD inheritance
|
|
|
|
# PWD should be imported and respected by fish
|
|
|
|
|
2019-01-22 22:07:25 +00:00
|
|
|
cd $oldpwd
|
2019-01-22 21:07:55 +00:00
|
|
|
mkdir -p $base/realhome
|
|
|
|
set fish_path $PWD/../test/root/bin/fish
|
|
|
|
ln -s $base/realhome $base/linkhome
|
|
|
|
cd $base/linkhome
|
2019-02-18 21:11:01 +00:00
|
|
|
set -l real_getcwd (pwd -P)
|
2019-01-22 21:07:55 +00:00
|
|
|
env HOME=$base/linkhome $fish_path -c 'echo PWD is $PWD'
|
|
|
|
|
2019-02-18 21:11:01 +00:00
|
|
|
# Do not inherit a virtual PWD that fails to resolve to getcwd (#5647)
|
|
|
|
|
|
|
|
env HOME=$base/linkhome PWD=/tmp $fish_path -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"
|
|
|
|
|
|
|
|
env HOME=$base/linkhome PWD=/path/to/nowhere $fish_path -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"
|
|
|
|
|
2019-03-26 09:11:36 +00:00
|
|
|
# $CDPATH
|
|
|
|
logmsg CDPATH
|
|
|
|
set -g CDPATH $base
|
|
|
|
cd linkhome
|
|
|
|
test $PWD = $base/linkhome; and echo Gone to linkhome via CDPATH
|
|
|
|
set -g CDPATH /tmp
|
|
|
|
cd $base
|
|
|
|
test $PWD = $base; and echo Gone to base
|
|
|
|
cd linkhome
|
|
|
|
test $PWD = $base/linkhome; and echo Gone to linkhome via implicit . in CDPATH
|
2019-02-18 21:11:01 +00:00
|
|
|
|
2019-01-22 22:07:25 +00:00
|
|
|
# cd back before removing the test directory again.
|
|
|
|
cd $oldpwd
|
|
|
|
rm -Rf $base
|