diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2016-07-15 00:34:48 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2016-07-15 00:40:37 +1200 |
commit | 8947c4c99f4c1ad92f23e59e84b224cf35e4ff81 (patch) | |
tree | 70718ad01791f2ca67133376252cf69a693b14ea /bash/bashrc.d/td.bash | |
parent | Terser `read -rd ''` idiom (diff) | |
download | dotfiles-8947c4c99f4c1ad92f23e59e84b224cf35e4ff81.tar.gz dotfiles-8947c4c99f4c1ad92f23e59e84b224cf35e4ff81.zip |
Quote expansions within parameter expansions
I made the incorrect assumption that it was safe not to do this;
expansions that include glob characters, for example, can cause
problems.
Diffstat (limited to 'bash/bashrc.d/td.bash')
-rw-r--r-- | bash/bashrc.d/td.bash | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/bash/bashrc.d/td.bash b/bash/bashrc.d/td.bash index 9f47c973..ffb9c973 100644 --- a/bash/bashrc.d/td.bash +++ b/bash/bashrc.d/td.bash @@ -1,7 +1,7 @@ # Complete filenames for td(1) _td() { local dir - dir=${TODO_DIR:-$HOME/Todo} + dir=${TODO_DIR:-"$HOME"/Todo} while IFS= read -rd '' fn ; do COMPREPLY[${#COMPREPLY[@]}]=$fn done < <( @@ -9,9 +9,9 @@ _td() { shopt -u dotglob local -a fns fns=("$dir"/"${COMP_WORDS[COMP_CWORD]}"*) - fns=("${fns[@]#$dir/}") + fns=("${fns[@]#"$dir"/}") ((${#fns[@]})) || exit 1 - printf '%s\0' "${fns[@]##$dir/}" + printf '%s\0' "${fns[@]##"$dir"/}" ) return } |