Browse Source

Minor fixes: add double-quoting to variables

Andrea Miglietta 7 years ago
parent
commit
3e318a311a
1 changed files with 4 additions and 4 deletions
  1. 4 4
      .bash_functions

+ 4 - 4
.bash_functions

@@ -24,11 +24,11 @@ man() {
 }
 
 function swap() {
-    local TMPFILE=swaptemp.$$
+    local TMPFILE="swaptemp.$$"
 
-    [ $# -ne 2 ] && echo "swap: 2 arguments needed" && return 1
-    [ ! -e $1 ]  && echo "swap: $1 does not exist"  && return 1
-    [ ! -e $2 ]  && echo "swap: $2 does not exist"  && return 1
+    [ "$#" -ne 2 ] && echo "swap: 2 arguments needed" && return 1
+    [ ! -e "$1" ]  && echo "swap: $1 does not exist"  && return 1
+    [ ! -e "$2" ]  && echo "swap: $2 does not exist"  && return 1
 
     mv "$1" "$TMPFILE"
     mv "$2" "$1"