fish-shell/tests/checks
Johannes Altmanninger 368017905e builtin commandline: -x for expanded tokens, supplanting -o
Issue #10194 reports Cobra completions do

    set -l args (commandline -opc)
    eval $args[1] __complete $args[2..] (commandline -ct | string escape)

The intent behind "eval" is to expand variables and tildes in "$args".
Fair enough. Several of our own completions do the same, see the next commit.

The problem with "commandline -o" + "eval" is that the former already
removes quotes that are  relevant for "eval". This becomes a problem if $args
contains quoted () or {}, for example this command will wrongly execute a
command substituion:

    git --work-tree='(launch-missiles)' <TAB>

It is possible to escape the string the tokens before running eval, but
then there will be no expansion of variables etc.  The problem is that
"commandline -o" only unescapes tokens so they end up in a weird state
somewhere in-between what the user typed and the expanded version.

Remove the need for "eval" by introducing "commandline -x" which expands
things like variables and braces. This enables custom completion scripts to
be aware of shell variables without eval, see the added test for completions
to "make -C $var/some/dir ".

This means that essentially all third party scripts should migrate from
"commandline -o" to "commandline -x". For example

    set -l tokens
    if commandline -x >/dev/null 2>&1
        set tokens (commandline -xpc)
    else
        set tokens (commandline -opc)
    end

Since this is mainly used for completions, the expansion skips command
substitutions.  They are passed through as-is (instead of cancelling or
expanding to nothing) to make custom completion scripts work reasonably well
in the common case. Of course there are cases where we would want to expand
command substitutions here, so I'm not sure.
2024-01-27 09:28:06 +01:00
..
broken-config/fish Port config tests to littlecheck 2019-06-25 22:31:06 +02:00
abbr.fish Port builtins/string to Rust 2023-07-27 22:00:03 -07:00
alias.fish Add the possibility to ignore arguments in alliases (#9199) 2022-09-11 09:55:11 +02:00
andandoror.fish Update tests for changed error output 2021-11-03 22:54:55 -07:00
andor.fish Don't skip caret for some errors 2022-08-12 18:38:47 +02:00
argparse.fish tests/argparse: Use set -l 2022-06-27 17:50:40 +02:00
bad-option.fish Port and adopt main written in Rust 2023-09-05 11:38:59 +02:00
basic.fish Encode all ENCODE_DIRECT codepoints with encode_direct 2023-12-10 09:29:42 +01:00
bind.fish Clean up tests/checks/bind.fish 2023-12-29 16:26:39 -08:00
braces.fish Reindent functions to remove useless quotes 2020-03-09 19:46:43 +01:00
broken-config.fish Don't segfault if user has an invalid locale 2023-08-03 19:55:05 +02:00
builtinbuiltin.fish builtin builtin: Print help if run without an action to do 2023-08-09 17:26:07 +02:00
caller-exit.fish functions: list caller-exit handlers correctly 2023-02-18 18:35:40 +01:00
caller-observer.fish Fix up --on-job-exit caller 2020-02-08 16:23:25 -08:00
cd.fish completions: Offer ../ and ./ again (#9477) 2023-01-16 10:05:01 +01:00
check-all-fish-files.fish Revert "Revert "Speed up check-all-fish-files when executed locally"" 2021-03-06 17:13:20 -06:00
check-completions.fish source the files instead 2022-04-21 17:40:25 +02:00
check-translations.fish Add a test to check format strings in translations 2021-10-18 17:02:17 +02:00
cmdsub-limit.fish Add acceptable errors to tests 2022-08-12 18:38:47 +02:00
cmdsub.fish Fix spurious syntax error on escaped $@ inside quoted command substitution 2022-04-03 16:18:47 +02:00
colon-delimited-var.fish Clean up how PATH and CDPATH munging occurs 2019-11-02 16:48:08 -07:00
command-1.fish Port most of the invocation tests to littlecheck 2019-06-25 20:56:29 +02:00
command-2.fish Port most of the invocation tests to littlecheck 2019-06-25 20:56:29 +02:00
command-not-found.fish Pass location of the *command* node without decorators 2022-08-12 18:38:47 +02:00
command-vars-persist.fish Port most of the invocation tests to littlecheck 2019-06-25 20:56:29 +02:00
commandline.fish commandline: Add --is-valid option (#8142) 2021-08-14 11:29:22 +02:00
complete-group-order.fish Test complete builtin sort of (sorted + unsorted) completions 2022-10-31 16:52:44 -05:00
complete.fish builtin commandline: -x for expanded tokens, supplanting -o 2024-01-27 09:28:06 +01:00
complete_directories.fish __fish_complete_directories: Remove --foo= from token 2023-03-27 22:57:34 +02:00
contains_opt.fish Reindent functions to remove useless quotes 2020-03-09 19:46:43 +01:00
count.fish Port count test to littlecheck 2019-06-26 21:19:40 +02:00
deep-cmdsub.fish Add a test for deep command substitutions 2020-01-18 11:50:50 -08:00
default-setup-path.fish tests: Remove a misunderstanding 2023-09-15 20:04:13 +02:00
directory-redirect.fish Fix tests 2020-01-19 15:07:06 +01:00
disown-parent.fish Add a tricky test to verify disowning an in-flight job 2019-12-08 11:44:21 -08:00
empty.fish Run fish_indent on all our fish scripts 2020-01-13 20:34:22 +01:00
env.fish Correctly mark a node when erasing an exported variable 2019-06-28 11:22:49 -07:00
eval.fish Add more tests 2022-08-12 18:38:47 +02:00
exec.fish Apply variable overrides for exec 2023-10-06 18:15:25 +02:00
exit-status-with-closing-stderr.fish Run fish_indent on all our fish scripts 2020-01-13 20:34:22 +01:00
expansion.fish Add hint to error message about cmdsub in command position 2023-11-18 12:26:45 +01:00
fds.fish tests/fd: Error out early if more fds are open 2022-06-17 09:33:42 +02:00
features-ampersand-nobg-in-token1.fish Teach fish_indent about our feature flags 2021-07-23 22:58:51 +02:00
features-nocaret1.fish Force stderr-nocaret feature flag on 2022-04-15 13:42:38 +02:00
features-nocaret2.fish Port most of the invocation tests to littlecheck 2019-06-25 20:56:29 +02:00
features-nocaret3.fish Force stderr-nocaret feature flag on 2022-04-15 13:42:38 +02:00
features-nocaret4.fish Port most of the invocation tests to littlecheck 2019-06-25 20:56:29 +02:00
features-qmark1.fish Disable ? as a glob by default 2024-01-24 21:17:36 -06:00
features-qmark2.fish Port most of the invocation tests to littlecheck 2019-06-25 20:56:29 +02:00
features-string-backslashes-off.fish tests, CHANGELOG: regex-easyesc 2019-08-13 22:56:31 -07:00
features-string-backslashes.fish tests, CHANGELOG: regex-easyesc 2019-08-13 22:56:31 -07:00
fish_add_path.fish Add a test for fish_add_path with relative paths 2023-09-29 16:54:23 +02:00
fish_exit.fish Correct "fire_exit" event back to "fish_exit" 2024-01-13 15:20:59 -08:00
fish_user_paths.fish Deduplicate $fish_user_paths automatically 2021-07-14 16:37:30 +02:00
for.fish Don't fire variable set event before entering a for-loop 2021-10-28 16:32:58 +02:00
function-definition.fish Properly print leading comments and indentation in functions 2020-01-03 14:40:28 -08:00
function.fish function: Fix a broken format string 2023-12-01 18:15:11 +01:00
functions.fish functions: Fix command name 2023-08-18 17:16:44 +02:00
git.fish tests/git: Also give the email to stash 2023-02-15 20:11:46 +01:00
glob.fish tests: Don't rely on $HOME existing 2020-12-29 12:48:11 +01:00
history.fish history: Refuse to merge in private mode 2022-07-01 20:10:18 +02:00
indent.fish fish_indent: Another crash 2024-01-10 20:56:13 +01:00
init-command-2.fish Port most of the invocation tests to littlecheck 2019-06-25 20:56:29 +02:00
init-command-mix-ordering.fish Port most of the invocation tests to littlecheck 2019-06-25 20:56:29 +02:00
init-command-mix.fish Port most of the invocation tests to littlecheck 2019-06-25 20:56:29 +02:00
init-command.fish Port most of the invocation tests to littlecheck 2019-06-25 20:56:29 +02:00
init-unreadable-cwd.fish Ignore unreadable cwd error harder 2020-02-14 20:09:07 +01:00
invocation.fish Fix a deadlock affecting fish_config 2023-10-07 15:20:14 -07:00
job-control-noninteractive.fish tests: Remove unnecessary status fish-path 2021-03-10 18:04:04 +01:00
job-control-not-a-tty.fish terminal_maybe_give_to_job to stop returning error on ENOTTY 2020-04-18 16:26:54 -07:00
job-ids.fish tests/job-ids: Wait for job to die 2020-01-25 14:06:34 +01:00
jobs-are-escaped.fish [tests] added test for escaped job summary 2023-07-10 18:38:26 +02:00
jobs.fish disown: Fix a format string 2023-11-29 16:59:53 +01:00
line-continuation.fish Reformat fish scripts with escaped newline changes to fish_indent 2020-03-15 21:01:11 +01:00
line-number.fish Update tests for changed error output 2021-11-03 22:54:55 -07:00
locale-numeric.fish Move the numeric locale tests to a different file 2021-08-17 15:36:07 +02:00
locale.fish Make \x the same as \X 2022-10-09 15:24:01 +02:00
loops.fish Add acceptable errors to tests 2022-08-12 18:38:47 +02:00
math.fish tinyexpr: Check for wcstod errors 2023-08-25 16:15:52 +02:00
no-config.fish Only use DATADIR in $fish_function_path if no-config is used 2021-05-01 18:59:25 +02:00
no-execute.fish Don't replace tilde for error messages if we have no $HOME 2023-12-28 10:19:48 +01:00
noshebang.fish Disable shebangless script tests in CI with sanitizers 2022-12-02 17:32:52 -08:00
not.fish Declare that two "not" keywords cancel each other out 2021-12-28 19:32:30 +01:00
nuls.fish Truncate builtin arguments on NUL 2023-06-24 21:26:44 +02:00
path.fish Stop using path sort in some path tests 2023-08-07 19:56:27 -07:00
pipeline-pgroup.fish tests: Pass $fish as a variable in some cases 2020-10-06 17:40:22 +02:00
pipestatus.fish Improve error for redirections to invalid paths 2021-11-20 17:44:05 +01:00
printf.fish printf: Fix octal escapes with leading zeroes 2023-10-05 15:39:50 +02:00
prompt.fish prompt_pwd: Fix missing -- 2023-12-25 18:46:23 +01:00
psub.fish Reindent functions to remove useless quotes 2020-03-09 19:46:43 +01:00
random.fish Port random to rust 2023-02-19 21:01:46 +01:00
rc-returned.fish Port most of the invocation tests to littlecheck 2019-06-25 20:56:29 +02:00
read.fish Fix regression in split_string_tok() 2024-01-18 10:24:40 +01:00
realpath.fish realpath: Use physical PWD 2022-07-18 20:45:30 +02:00
redirect.fish Print "^^" for a 2-wide error 2022-08-12 18:38:47 +02:00
regex-import.fish Correct behavior of string match variable import with multiple arguments 2021-04-20 15:15:52 -07:00
return.fish Use -- before seq for negative numbers 2022-10-23 13:53:36 -07:00
scoping.fish Update tests for changed error output 2021-11-03 22:54:55 -07:00
self-signal-usr1.fish Stop storing block_io in job_t 2019-12-11 16:34:20 -08:00
set.fish set: Fix set -e without arguments 2024-01-01 16:21:08 +01:00
setenv.fish Port setenv tests to littlecheck 2019-07-09 10:02:50 -07:00
sigint.fish tests: Remove unnecessary status fish-path 2021-03-10 18:04:04 +01:00
sigint2.fish Disable job control inside command substitutions 2021-08-18 22:20:03 +08:00
signal.fish Fix some tests for OpenIndiana 2021-06-24 18:17:10 +02:00
slices.fish Revert "Disallow escaped characters in variable expansion" 2021-06-10 16:46:17 +02:00
stack-overflow.fish Make CALL_STACK_LIMIT_EXCEEDED_ERR_MSG more generic 2022-10-25 13:40:21 -05:00
status-command.fish Skip some tests on OpenBSD 2021-06-24 20:46:03 +02:00
status-value.fish Log original exit code used when a builtin returns a negative exit code 2024-01-05 16:52:18 +01:00
status.fish qmark-noglob: Set group back 2024-01-25 18:26:48 +01:00
string-advanced.fish Test string replace transforms 2021-03-21 10:03:35 +01:00
string.fish Fix behaviour in the presence of non-visible width 2023-07-27 22:00:03 -07:00
switch.fish Add acceptable errors to tests 2022-08-12 18:38:47 +02:00
symlinks-not-overwritten.fish Clean up more mktemp usage residue 2022-09-23 11:05:58 -05:00
syntax-error-location.fish Add hint to error message about cmdsub in command position 2023-11-18 12:26:45 +01:00
test.fish Remove superfluous CHECK lines 2022-09-21 18:37:38 +02:00
threads.fish Reindent functions to remove useless quotes 2020-03-09 19:46:43 +01:00
time.fish parse_util: Only reject time in a pipeline without decorator 2023-08-25 19:45:15 +02:00
tmux-abbr.fish Revert "Skip tmux tests on Github Actions macOS" 2022-06-12 14:24:55 -07:00
tmux-bind.fish Fix arithmetic overflow in up-line 2024-01-10 09:38:45 +01:00
tmux-complete.fish tests: More slack for ASAN 2023-05-11 22:14:12 +02:00
tmux-history-search.fish Fix regression when erasing word in search field 2024-01-27 03:46:26 +01:00
tmux-prompt.fish Revert "Skip tmux tests on Github Actions macOS" 2022-06-12 14:24:55 -07:00
trace.fish Change fish_trace prefix to "->" instead of plusses 2020-12-11 21:24:33 +01:00
trap.fish Allow trapping SIGINT and SIGTERM in scripts 2022-05-28 17:44:13 -07:00
trap_print.fish Add regression test for trap -p 2022-10-24 15:36:02 -05:00
type.fish Rewrite the type builtin in rust 2023-04-16 11:27:08 +02:00
ulimit.fish ulimit: add basic tests 2022-03-24 10:23:04 +08:00
umask.fish umask: Correctly handle empty symbolic value 2023-12-31 19:39:23 +01:00
variable-assignment.fish Don't skip caret for some errors 2022-08-12 18:38:47 +02:00
vars_as_commands.fish Add length to the parse_util syntax errors 2022-08-12 18:38:47 +02:00
version.fish Port most of the invocation tests to littlecheck 2019-06-25 20:56:29 +02:00
wait.fish Add a test and CHANGELOG fix for #9096 2022-07-30 10:14:19 -07:00
wildcard.fish wildcard: Check trailing components against 2024-01-09 19:08:52 +01:00
wraps.fish Sort and deduplicate output of complete -C 2022-10-31 16:52:36 -05:00
zero_based_array.fish Add more tests for literal zero indexes 2021-08-15 13:48:41 -05:00