Skip to content

Commit 18f566d

Browse files
committed
Fix variable expansion not being double quoted
- prevent potential unwanted word splitting or globbing - "When in doubt, always double-quote your parameter expansions." -- http://mywiki.wooledge.org/Quotes - detected the issue using ShellCheck, a bash static analysis tool (http://www.shellcheck.net/)
1 parent 7de24c1 commit 18f566d

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

notes

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,30 @@ notes() {
1616
note() {
1717
if [ -e "$NOTES_DIR/$1.txt" ]
1818
then
19-
${PAGER:-less} $NOTES_DIR/$1.txt
19+
${PAGER:-less} "$NOTES_DIR/$1.txt"
2020
else
2121
notes
2222
fi
2323
}
2424

2525
new-note() {
26-
edit-note $1
26+
edit-note "$1"
2727
}
2828

2929
edit-note() {
30-
${EDITOR:-emacs} $NOTES_DIR/$1.txt
30+
${EDITOR:-emacs} "$NOTES_DIR/$1.txt"
3131
}
3232

3333
archive-note() {
34-
mkdir -p $NOTES_DIR/.archive
35-
mv -i $NOTES_DIR/$1.txt $NOTES_DIR/.archive
34+
mkdir -p "$NOTES_DIR/.archive"
35+
mv -i "$NOTES_DIR/$1.txt" "$NOTES_DIR/.archive"
3636
}
3737

3838
_find_notes() {
3939
NOTES=()
40-
for i in `(find $NOTES_DIR -name '*.txt' -not -path $NOTES_DIR'/.archive/*')`
40+
for i in `(find "$NOTES_DIR" -name '*.txt' -not -path "$NOTES_DIR"'/.archive/*')`
4141
do
42-
NOTES=("${NOTES[@]}" "`basename $i .txt`")
42+
NOTES=("${NOTES[@]}" "`basename "$i" .txt`")
4343
done
4444
}
4545

@@ -50,7 +50,7 @@ _note_complete() {
5050
cur="${COMP_WORDS[COMP_CWORD]}"
5151
prev="${COMP_WORDS[COMP_CWORD-1]}"
5252
opts="${NOTES[@]}"
53-
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
53+
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
5454
return 0
5555
}
5656

0 commit comments

Comments
 (0)