rauchg / spot

Tiny file search utility (bash)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

shellcheck reports multiple warnings for spot.sh

nodiscc opened this issue · comments

Hi, thanks for writing this! I'm trying to package the script for Debian and was advised to run shellcheck (http://hackage.haskell.org/package/ShellCheck) on the script before going further. It reports some thngs that you might want to fix.

In spot.sh line 31:
cyan=`echo -e '\033[96m'`
     ^-- SC2006: Use $(..) instead of deprecated `..`


In spot.sh line 32:
reset=`echo -e '\033[39m'`
      ^-- SC2006: Use $(..) instead of deprecated `..`


In spot.sh line 115:
    dir=`echo $1 | sed "s/\/$//"`
        ^-- SC2006: Use $(..) instead of deprecated `..`
         ^-- SC2001: See if you can use ${variable//search/replace} instead.
              ^-- SC2086: Double quote to prevent globbing and word splitting.


In spot.sh line 155:
if [ $filename ]; then
     ^-- SC2086: Double quote to prevent globbing and word splitting.


In spot.sh line 160:
eval "find "$dir" $findopt -type f $exclude -print0" \
            ^-- SC2027: The surrounding quotes actually unquote this. Remove or escape them.
            ^-- SC2086: Double quote to prevent globbing and word splitting.


In spot.sh line 161:
  | GREP_COLOR="1;33;40" xargs -0 grep $grepopt -e "`echo $@`" \
                                       ^-- SC2086: Double quote to prevent globbing and word splitting.
                                                    ^-- SC2116: Useless echo? Instead of 'cmd $(echo foo)', just use 'cmd foo'.
                                                    ^-- SC2006: Use $(..) instead of deprecated `..`
                                                          ^-- SC2068: Double quote array expansions, otherwise they're like $* and break on spaces.


In spot.sh line 165:
  | awk -v linenums=$linenums -v reset=`tput sgr0` -v colors=$colors -v mline=$mline '{
                                       ^-- SC2046: Quote this to prevent word splitting.
                                       ^-- SC2006: Use $(..) instead of deprecated `..`

As you can see it's rather minor things, but there are some quoting warnings that might cause problems in the future. I'll submit a pull request when I get some time, hope you can begin fixing this in the meantime! By the way, the request for packaging is at https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=688866 and any help is welcome.

Thanks again