2014-09-20 00:26:10 -07:00
# vim: set filetype=fish:
2012-05-11 18:59:38 -07:00
2016-07-04 20:28:21 -07:00
# Regression test for issue #3129. In previous versions these statements would
# cause an `assert()` to fire thus killing the shell.
complete -c pkill -o ''
complete -c pkill -l ''
complete -c pkill -s ''
2012-05-11 18:59:38 -07:00
# Test that conditions that add or remove completions don't deadlock, etc.
# We actually encountered some case that was effectively like this (Issue 2 in github)
complete --command AAAA -l abcd --condition 'complete -c AAAA -l efgh'
2014-09-02 15:25:45 -07:00
echo "AAAA:"
complete -C 'AAAA -' | sort
echo "AAAA:"
complete -C 'AAAA -' | sort
2012-05-11 18:59:38 -07:00
complete --command BBBB -l abcd --condition 'complete -e --command BBBB -l abcd'
2014-09-02 15:25:45 -07:00
echo "BBBB:"
2012-05-11 18:59:38 -07:00
complete -C 'BBBB -'
2014-09-02 15:25:45 -07:00
echo "BBBB:"
2012-05-11 18:59:38 -07:00
complete -C 'BBBB -'
2014-09-02 15:25:45 -07:00
# Test that erasing completions works correctly
echo
2014-09-02 15:52:56 -07:00
function sort
# GNU sort is really stupid, a non-C locale seems to make it assume --dictionary-order
# If I wanted --dictionary-order, I would have specified --dictionary-order!
env LC_ALL = C sort $argv
end
2014-09-02 15:25:45 -07:00
complete -c CCCC -l bar
complete -c CCCC -l baz
complete -c CCCC -o bar
complete -c CCCC -o foo
complete -c CCCC -s a
complete -c CCCC -s b
echo "CCCC:"
complete -C 'CCCC -' | sort
complete -c CCCC -l bar -e
echo "CCCC:"
complete -C 'CCCC -' | sort
complete -c CCCC -o foo -e
echo "CCCC:"
complete -C 'CCCC -' | sort
complete -c CCCC -s a -e
echo "CCCC:"
complete -C 'CCCC -' | sort
complete -c CCCC -e
echo "CCCC:"
complete -C 'CCCC -' | sort
2014-09-20 00:26:10 -07:00
2016-12-08 02:00:24 -08:00
echo "Test that -- suppresses option completions"
complete -c TestDoubleDash -l TestDoubleDashOption
complete -C 'TestDoubleDash -' | sort
echo "Expect no output:" ( complete -C 'TestDoubleDash -- -' | sort )
2016-12-09 12:14:14 -08:00
# fish seems to have always handled "exclusive" options strangely
# It seems to treat them the same as "old-style" (single-dash) long options
echo "Testing exclusive options"
complete -c TestExclusive -x -s Q
complete -c TestExclusive -x -s W
complete -c TestExclusive -s A
echo "Expect -A -Q -W:" ( complete -C 'TestExclusive -' | sort | string join ' ' )
echo "Expect -AQ -AW:" ( complete -C 'TestExclusive -A' | sort | string join ' ' )
echo "Expect no output 1:" ( complete -C 'TestExclusive -Q' )
echo "Expect no output 2:" ( complete -C 'TestExclusive -W' )
2016-12-08 02:00:24 -08:00
2014-09-20 00:26:10 -07:00
# Test that directory completions work correctly
if begin ; rm -rf test6.tmp.dir; and mkdir test6.tmp.dir; end
pushd test6.tmp.dir
set -l dir ( mktemp -d XXXXXXXX)
if complete -C $dir | grep " ^ $dir /.*Directory " > /dev/null
echo "implicit cd complete works"
else
echo "no implicit cd complete"
end
if complete -C " command $dir " | grep " ^ $dir /.*Directory " > /dev/null
echo "implicit cd complete incorrect after 'command'"
else
echo "no implicit cd complete after 'command'"
end
popd
if begin
2014-09-20 00:35:51 -07:00
set -l PATH $PWD /test6.tmp.dir $PATH ^ /dev/null
2014-09-20 00:26:10 -07:00
complete -C $dir | grep " ^ $dir /.*Directory " > /dev/null
end
echo "incorrect implicit cd from PATH"
else
echo "PATH does not cause incorrect implicit cd"
end
rm -rf test6.tmp.dir
else
echo "error: could not create temp environment" > & 2
end
2016-04-07 15:24:52 -07:00
# Test command expansion with parened PATHs (#952)
begin
set -l parened_path $PWD /'test6.tmp2.(paren).dir'
set -l parened_subpath $parened_path /subdir
if not begin
rm -rf $parened_path
and mkdir $parened_path
and mkdir $parened_subpath
and ln -s /bin/ls $parened_path /'__test6_(paren)_command'
and ln -s /bin/ls $parened_subpath /'__test6_subdir_(paren)_command'
end
echo "error: could not create command expansion temp environment" > & 2
end
# Verify that we can expand commands when PATH has parens
set -l PATH $parened_path $PATH
set -l completed ( complete -C__test6_ | cut -f 1 -d \t )
if test " $completed " = '__test6_(paren)_command'
echo "Command completion with parened PATHs test passed"
else
echo " Command completion with parened PATHs test failed. Expected __test6_(paren)_command, got $completed " > & 2
end
# Verify that commands with intermediate slashes do NOT expand with respect to PATH
set -l completed ( complete -Csubdir /__test6_subdir)
if test -z " $completed "
echo "Command completion with intermediate slashes passed"
else
echo " Command completion with intermediate slashes: should output nothing, instead got $completed " > & 2
end
rm -rf $parened_path
end