mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-12 21:18:53 +00:00
e66f6878b5
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?
49 lines
1.6 KiB
Fish
49 lines
1.6 KiB
Fish
# Explicitly overriding HOME/XDG_CONFIG_HOME is only required if not invoking via `make test`
|
|
# RUN: fish=%fish %fish %s
|
|
|
|
mkdir -p $XDG_CONFIG_HOME/fish
|
|
|
|
# fish_variables
|
|
set -l target_file $XDG_CONFIG_HOME/fish/target_fish_variables
|
|
set -l fish_variables $XDG_CONFIG_HOME/fish/fish_variables
|
|
set -l backup_file $XDG_CONFIG_HOME/fish/fish_variables_backup
|
|
|
|
echo >$target_file
|
|
cp $target_file $backup_file
|
|
ln -sf $target_file $fish_variables
|
|
$fish -c 'set -U variable value'
|
|
|
|
if not test -L $fish_variables
|
|
echo fish_variables has been overwritten
|
|
else if cmp $target_file $backup_file >/dev/null
|
|
echo fish_variables was never written
|
|
else
|
|
echo fish_variables is still a symlink
|
|
end
|
|
# CHECK: fish_variables is still a symlink
|
|
rm $fish_variables
|
|
|
|
|
|
# fish_history
|
|
set -l history_file $XDG_DATA_HOME/fish/fish_history
|
|
set -l target_file $XDG_DATA_HOME/fish/target_fish_history
|
|
set -l backup_file $XDG_DATA_HOME/fish/fish_history_backup
|
|
|
|
echo '- cmd: echo I will be deleted from history
|
|
when: 1614577746' >$target_file
|
|
cp $target_file $backup_file
|
|
ln -sf $target_file $history_file
|
|
# The one way to ensure non-interactive fish writes to the history file
|
|
$fish -c 'echo all | history delete deleted | grep echo'
|
|
# CHECK: [1] echo I will be deleted from history
|
|
|
|
if not test -L $history_file
|
|
echo fish_history has been overwritten
|
|
else if cmp $target_file $backup_file &>/dev/null
|
|
# cmp writes to stderr when one file is empty, thus &> above
|
|
echo fish_history was never written
|
|
else
|
|
echo fish_history is still a symlink
|
|
end
|
|
# CHECK: fish_history is still a symlink
|
|
rm $history_file
|