From 6281ea2b7730d0fa443b6a42c87885aac3bd19fb Mon Sep 17 00:00:00 2001 From: Tom King Date: Fri, 23 Jun 2017 11:25:21 -0700 Subject: [PATCH 1/2] quote vars to avoid splitting & file glob w/ echo, log, exec --- rmate | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rmate b/rmate index e203b78..3e44601 100755 --- a/rmate +++ b/rmate @@ -149,7 +149,7 @@ function canonicalize { result="$dir/$result" fi fi - echo $result + echo "$result" } while [[ "${1:0:1}" = "-" || "$1" =~ ^\+([0-9]+)$ ]]; do @@ -197,7 +197,7 @@ while [[ "${1:0:1}" = "-" || "$1" =~ ^\+([0-9]+)$ ]]; do verbose=true ;; --version) - echo $version_string + echo "$version_string" exit 1 ;; -h|-\?|--help) @@ -253,7 +253,7 @@ function open_file { if [ "$filepath" != "-" ]; then realpath=`canonicalize "$filepath"` - log $realpath + log "$realpath" if [ -d "$filepath" ]; then echo "$filepath is a directory and rmate is unable to handle directories." @@ -387,7 +387,7 @@ function handle_connection { # connect to textmate and send command # -exec 3<> /dev/tcp/$host/$port +exec 3<> "/dev/tcp/$host/$port" # checking return value of exec here is clearer; skip warning # shellcheck disable=SC2181 From 195a13cfdf194e103e38d399a28c97792f90a32c Mon Sep 17 00:00:00 2001 From: Tom King Date: Fri, 23 Jun 2017 11:58:28 -0700 Subject: [PATCH 2/2] to simplify PR, remove other shellcheck-driven comments & changes --- rmate | 8 -------- 1 file changed, 8 deletions(-) diff --git a/rmate b/rmate index 3e44601..a42de26 100755 --- a/rmate +++ b/rmate @@ -52,8 +52,6 @@ function hostname_command(){ fi } -# intent is to execute hostname command, so disable the warning -# shellcheck disable=SC2091 hostname=$($(hostname_command)) # default configuration @@ -79,8 +77,6 @@ function load_config { fi } -# "home" is from earlier eval so disable warning about unassigned reference -# shellcheck disable=SC2154 for i in "/etc/${0##*/}" $home/."${0##*/}/${0##*/}.rc" $home/."${0##*/}.rc"; do load_config "$i" done @@ -296,8 +292,6 @@ function open_file { fi if [ "$filepath" != "-" ] && [ -f "$filepath" ]; then - # ls is used to get filesize, so skip warning about find - # shellcheck disable=SC2012 filesize=`ls -lLn "$realpath" | awk '{print $5}'` echo "data: $filesize" 1>&3 cat "$realpath" 1>&3 @@ -389,8 +383,6 @@ function handle_connection { # exec 3<> "/dev/tcp/$host/$port" -# checking return value of exec here is clearer; skip warning -# shellcheck disable=SC2181 if [ $? -gt 0 ]; then echo "Unable to connect to TextMate on $host:$port" exit 1