diff options
author | Jochen Nitschke <j.nitschke+logerrit@ok.de> | 2017-01-11 11:49:18 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2017-01-13 20:54:53 +0000 |
commit | 1ad45ecbf172bca9d3eeff8750a0eb13731c322e (patch) | |
tree | 028b77d1407e5ec4489fb3cbf87f9708d2556be0 /solenv | |
parent | e81454861f4fa2d5d6bbdc2c0eb6af14347c8205 (diff) |
tdf#105204 shellcheck
addressed issues in order of appearance:
warnings
- prefer [..] && [..] (SC2166)
- unused 'awkCMD' (SC2034)
- typo currentFirstLIne -> currentFirstLine (SC2154)
recommendations
- use $(..) instead of `..` (SC2006)
- remove $ on arithmetic variable OPTIND (SC2004)
- double quote to prevent globbing in $findArgs (SC2086)
Change-Id: I2d2b7aecac97b2e4e0df8ce556c85995d4ecf7cf
Reviewed-on: https://gerrit.libreoffice.org/33003
Reviewed-by: Michael Stahl <mstahl@redhat.com>
Tested-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'solenv')
-rwxr-xr-x | solenv/bin/add-modelines | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/solenv/bin/add-modelines b/solenv/bin/add-modelines index fcb26bc3639d..7dff27b84382 100755 --- a/solenv/bin/add-modelines +++ b/solenv/bin/add-modelines @@ -43,10 +43,10 @@ ModelineReplace="false" function SetEnvironment() { - if [ -n "$(which tail)" -a -n "$(which head)" ]; then + if [ -n "$(which tail)" ] && [ -n "$(which head)" ]; then { - headCMD=`which head` - tailCMD=`which tail` + headCMD=$(which head) + tailCMD=$(which tail) } else { @@ -55,21 +55,13 @@ function SetEnvironment() } fi if [ -n "$(which find)" ]; then - findCMD=`which find` + findCMD=$(which find) else { echo "Missing find, exiting..." exit 1 } fi - if [ -n "$(which awk)" ]; then - awkCMD=`which awk` - else - { - echo "Missing awk, exiting..." - exit 1 - } - fi } function EditFile() @@ -80,12 +72,12 @@ function EditFile() FileToEdit="$1" - currentFirstLine=`$headCMD -1 "$FileToEdit"` - currentLastLine=`$tailCMD -1 "$FileToEdit"` + currentFirstLine=$($headCMD -1 "$FileToEdit") + currentLastLine=$($tailCMD -1 "$FileToEdit") case "$ModelineReplace" in "true" ) - if [ "${currentFirstLIne:0:6}" = "${FirstLine:0:6}" ]; then + if [ "${currentFirstLine:0:6}" = "${FirstLine:0:6}" ]; then { echo "$FirstLine" > "$FileToEdit".new $tailCMD -n +2 "$FileToEdit" >> "$FileToEdit".new @@ -144,7 +136,7 @@ while getopts "zs:p:" opt; do done if [ $OPTIND -gt 1 ]; then - shift $(($OPTIND - 1)) + shift $((OPTIND - 1)) fi if [ $# -gt 1 ]; then @@ -167,9 +159,9 @@ for FileType in ${SourceFiles}; do done # This gets rid of the final " -a " in the find argument list -findArgs="${findArgs:0:(${#findArgs}-3)}" +findArgs=(${findArgs:0:(${#findArgs}-3)}) -for file in $($findCMD $findArgs); do +for file in $($findCMD "${findArgs[@]}"); do EditFile "$file" echo "Completed: " "$file" done |