diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2015-10-21 13:08:09 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2015-10-21 13:08:09 +1300 |
commit | dcfc80aaa112498498d93bae3ae0eb2088244c47 (patch) | |
tree | 889854ba1c96f1c86465da1bbd5cc87f0c8d4b9f /bash/bashrc.d/fnl.bash | |
parent | Handle spaces correctly in completions (diff) | |
download | dotfiles-dcfc80aaa112498498d93bae3ae0eb2088244c47.tar.gz dotfiles-dcfc80aaa112498498d93bae3ae0eb2088244c47.zip |
Tidy up completion considerably; no more compgen
* Remove all instances of compgen; for filename completion it's quite
broken as it relies on implicit wordsplitting in array context, and
doesn't have an option to print with a null delimiter; replaced with
manual for/while loops instead
* Add IFS= to while/read loops over filenames
* Use "dirname/s" instead of "dir/s" variables to avoid keyword
collisions and for clarity
* Remove some unnecessary variables
* Use shorter syntax for loop exit conditions
* Move completion options into functions where applicable rather than
having them on the completion definition itself
Diffstat (limited to 'bash/bashrc.d/fnl.bash')
-rw-r--r-- | bash/bashrc.d/fnl.bash | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/bash/bashrc.d/fnl.bash b/bash/bashrc.d/fnl.bash index 9f894654..efdaa1c5 100644 --- a/bash/bashrc.d/fnl.bash +++ b/bash/bashrc.d/fnl.bash @@ -23,20 +23,20 @@ fnl() { fi # Create a temporary directory or bail - local template dir + local template dirname template=$FUNCNAME.$1.XXXXX - if ! dir=$(mktemp -dt -- "$template") ; then + if ! dirname=$(mktemp -dt -- "$template") ; then return fi # Run the command and save its exit status local ret - "$@" >"$dir"/stdout 2>"$dir"/stderr + "$@" >"$dirname"/stdout 2>"$dirname"/stderr ret=$? # Note these are *not* local variables # shellcheck disable=SC2034 - fnl_stdout=$dir/stdout fnl_stderr=$dir/stderr + fnl_stdout=$dirname/stdout fnl_stderr=$dirname/stderr declare -p fnl_std{out,err} # Return the exit status of the command, not the declare builtin |