2024-04-12 18:19:32 +08:00
|
|
|
#RUN: %fish -C 'set -g fish (builtin realpath %fish)' %s
|
2020-02-08 05:10:55 +08:00
|
|
|
# Test that using variables as command names work correctly.
|
|
|
|
|
|
|
|
$EMPTY_VARIABLE
|
|
|
|
#CHECKERR: {{.*}}checks/vars_as_commands.fish (line {{\d+}}): The expanded command was empty.
|
|
|
|
#CHECKERR: $EMPTY_VARIABLE
|
2022-08-12 00:20:40 +08:00
|
|
|
#CHECKERR: ^~~~~~~~~~~~~~^
|
2020-02-08 05:10:55 +08:00
|
|
|
"$EMPTY_VARIABLE"
|
|
|
|
#CHECKERR: {{.*}}checks/vars_as_commands.fish (line {{\d+}}): The expanded command was empty.
|
|
|
|
#CHECKERR: "$EMPTY_VARIABLE"
|
2022-08-12 00:20:40 +08:00
|
|
|
#CHECKERR: ^~~~~~~~~~~~~~~~^
|
2020-02-08 05:10:55 +08:00
|
|
|
|
|
|
|
set CMD1 echo basic command as variable
|
|
|
|
$CMD1
|
|
|
|
#CHECK: basic command as variable
|
|
|
|
|
|
|
|
set CMD2 echo '(' not expanded again
|
|
|
|
$CMD2
|
|
|
|
#CHECK: ( not expanded again
|
|
|
|
|
|
|
|
# Test using variables with the builtin decorator
|
|
|
|
builtin $CMD1
|
|
|
|
#CHECK: basic command as variable
|
|
|
|
|
|
|
|
# Test implicit cd
|
|
|
|
set CMD3 /usr/bin
|
|
|
|
$CMD3 && echo $PWD
|
|
|
|
#CHECK: /usr/bin
|
|
|
|
|
2021-07-27 03:29:02 +08:00
|
|
|
# $status specifically is not valid, to avoid a common error
|
|
|
|
# with `if $status`
|
|
|
|
echo 'if $status; echo foo; end' | $fish --no-config
|
|
|
|
#CHECKERR: fish: $status is not valid as a command. See `help conditions`
|
|
|
|
#CHECKERR: if $status; echo foo; end
|
2022-08-12 22:53:31 +08:00
|
|
|
#CHECKERR: ^~~~~~^
|
2021-07-27 03:29:02 +08:00
|
|
|
echo 'not $status' | $fish --no-config
|
|
|
|
#CHECKERR: fish: $status is not valid as a command. See `help conditions`
|
|
|
|
#CHECKERR: not $status
|
2022-08-12 22:53:31 +08:00
|
|
|
#CHECKERR: ^~~~~~^
|
2021-07-27 03:29:02 +08:00
|
|
|
|
|
|
|
# Script doesn't run at all.
|
|
|
|
echo 'echo foo; and $status' | $fish --no-config
|
|
|
|
#CHECKERR: fish: $status is not valid as a command. See `help conditions`
|
|
|
|
#CHECKERR: echo foo; and $status
|
2022-08-12 22:53:31 +08:00
|
|
|
#CHECKERR: ^~~~~~^
|
2021-07-27 03:29:02 +08:00
|
|
|
|
|
|
|
echo 'set -l status_cmd true; if $status_cmd; echo Heck yes this is true; end' | $fish --no-config
|
|
|
|
#CHECK: Heck yes this is true
|
|
|
|
|
2022-08-11 23:31:01 +08:00
|
|
|
foo=bar $NONEXISTENT -c 'set foo 1 2 3; set --show foo'
|
|
|
|
#CHECKERR: {{.*}}checks/vars_as_commands.fish (line {{\d+}}): The expanded command was empty.
|
|
|
|
#CHECKERR: foo=bar $NONEXISTENT -c 'set foo 1 2 3; set --show foo'
|
|
|
|
#CHECKERR: ^~~~~~~~~~~^
|
|
|
|
|
2020-02-08 05:10:55 +08:00
|
|
|
exit 0
|