ElektraInitiative / libelektra

Elektra serves as a universal and secure framework to access configuration settings in a global, hierarchical key database.
https://www.libelektra.org
BSD 3-Clause "New" or "Revised" License
208 stars 123 forks source link

Shell recorder: shellcheck & checkbashisms #807

Closed KurtMi closed 7 years ago

KurtMi commented 8 years ago

I let shellcheck and checkbashisms check the shell_recorder.sh. I fixed the most, but the following are to hardcore for me.

$ checkbashisms -f shell_recorder.sh
possible bashism in shell_recorder.sh line 50 (${parm/?/pat[/str]}):
    command=$(echo ${proto//'$Mountpoint'/$Mountpoint})
possible bashism in shell_recorder.sh line 51 (${parm/?/pat[/str]}):
    command=$(echo ${command//'$File'/$DBFile})
possible bashism in shell_recorder.sh line 52 (${parm/?/pat[/str]}):
    command=$(echo ${command//'$Storage'/$Storage})
possible bashism in shell_recorder.sh line 53 (${parm/?/pat[/str]}):
    command=$(echo ${command//'$MountArgs'/$MountArgs})
possible bashism in shell_recorder.sh line 194 (<<< here string):
        cmd=$(cut -d ' ' -f1 <<< $line)
possible bashism in shell_recorder.sh line 197 (<<< here string):
                Mountpoint=$(cut -d ' ' -f2 <<< $line)
possible bashism in shell_recorder.sh line 200 (<<< here string):
                DBFile=$(cut -d ' ' -f2 <<< $line)
possible bashism in shell_recorder.sh line 203 (<<< here string):
                Storage=$(cut -d ' ' -f2 <<< $line)
possible bashism in shell_recorder.sh line 206 (<<< here string):
                MountArgs=$(cut -d ' ' -f2- <<< $line)
possible bashism in shell_recorder.sh line 209 (<<< here string):
                echo "$(cut -d ' ' -f2- <<< $line)"
possible bashism in shell_recorder.sh line 212 (<<< here string):
                DiffType=$(cut -d ' ' -f2 <<< $line)
possible bashism in shell_recorder.sh line 215 (<<< here string):
                RETCMP=$(cut -d ' ' -f2- <<< $line)
possible bashism in shell_recorder.sh line 218 (<<< here string):
                ERRORSCMP=$(cut -d ' ' -f2- <<< $line)
possible bashism in shell_recorder.sh line 221 (<<< here string):
                WARNINGSCMP=$(cut -d ' ' -f2- <<< $line)
possible bashism in shell_recorder.sh line 224 (<<< here string):
                STDOUTCMP=$(cut -d ' ' -f2- <<< $line)
possible bashism in shell_recorder.sh line 227 (<<< here string):
                STDERRCMP=$(cut -d ' ' -f2- <<< $line)
possible bashism in shell_recorder.sh line 230 (<<< here string):
                DIFFCMP=$(cut -d ' ' -f2- <<< $line)
possible bashism in shell_recorder.sh line 234 (<<< here string):
                ARG=$(cut -d ' ' -f2- <<< $line)

and

$ shellcheck shell_recorder.sh
In shell_recorder.sh line 200:
    while read line;
          ^-- SC2162: read without -r will mangle backslashes.

In shell_recorder.sh line 35:
    proto="$@"
          ^-- SC2124: Assigning an array to a string! Assign as array, or use * instead of @ to concatenate.
tom-wa commented 7 years ago

is there still anything left or is #831 enough ?

KurtMi commented 7 years ago

I think shellcheck has some issues, but please wait till #806 is merged or work from my branch.

tom-wa commented 7 years ago

can we close this issue ?

markus2330 commented 7 years ago

@KurtMi Can you rerun check bashism?

KurtMi commented 7 years ago

check bashism is happy now, but shellcheck has some complaints:


In shell_recorder.sh line 27:
if [ -z "@USE_CMAKE_KDB_COMMAND@" ]; then
         ^-- SC2157: Argument to -z is always false due to literal strings.
Can be ignored!

In shell_recorder.sh line 39:
    proto="$@"
          ^-- SC2124: Assigning an array to a string! Assign as array, or use * instead of @ to concatenate.

In shell_recorder.sh line 58:
    command=$(echo $proto | sed "s~\$Mountpoint~${Mountpoint}~g")
                   ^-- SC2086: Double quote to prevent globbing and word splitting.

In shell_recorder.sh line 59:
    command=$(echo $command | sed "s~\$File~${DBFile}~g")
                   ^-- SC2086: Double quote to prevent globbing and word splitting.

In shell_recorder.sh line 60:
    command=$(echo $command | sed "s~\$Storage~${Storage}~g")
                   ^-- SC2086: Double quote to prevent globbing and word splitting.

In shell_recorder.sh line 61:
    command=$(echo $command | sed "s~\$MountArgs~${MountArgs}~g")
                   ^-- SC2086: Double quote to prevent globbing and word splitting.

In shell_recorder.sh line 211:
    while read line;
          ^-- SC2162: read without -r will mangle backslashes.

In shell_recorder.sh line 215:
        cmd=$(echo $line|cut -d ' ' -f1)
                   ^-- SC2086: Double quote to prevent globbing and word splitting.

In shell_recorder.sh line 218:
                Mountpoint=$(echo $line|cut -d ' ' -f2)
                                  ^-- SC2086: Double quote to prevent globbing and word splitting.

In shell_recorder.sh line 221:
                DBFile=$(echo $line|cut -d ' ' -f2)
                              ^-- SC2086: Double quote to prevent globbing and word splitting.

In shell_recorder.sh line 222:
                if [ "$DBFile" = "File:" -o -z "$DBFile" ]; then
                                         ^-- SC2166: Prefer [ p ] || [ q ] as [ p -o q ] is not well defined.

In shell_recorder.sh line 227:
                Storage=$(echo $line|cut -d ' ' -f2)
                               ^-- SC2086: Double quote to prevent globbing and word splitting.

In shell_recorder.sh line 230:
                MountArgs=$(echo $line|cut -d ' ' -f2-)
                                 ^-- SC2086: Double quote to prevent globbing and word splitting.

In shell_recorder.sh line 233:
                echo "$(echo $line|cut -d ' ' -f2-)"
                     ^-- SC2005: Useless echo? Instead of 'echo $(cmd)', just use 'cmd'.
                             ^-- SC2086: Double quote to prevent globbing and word splitting.

In shell_recorder.sh line 236:
                DiffType=$(echo $line|cut -d ' ' -f2)
                                ^-- SC2086: Double quote to prevent globbing and word splitting.

In shell_recorder.sh line 239:
                RETCMP=$(echo $line|cut -d ' ' -f2-)
                              ^-- SC2086: Double quote to prevent globbing and word splitting.

In shell_recorder.sh line 242:
                ERRORSCMP=$(echo $line|cut -d ' ' -f2-)
                                 ^-- SC2086: Double quote to prevent globbing and word splitting.

In shell_recorder.sh line 245:
                WARNINGSCMP=$(echo $line|cut -d ' ' -f2-)
                                   ^-- SC2086: Double quote to prevent globbing and word splitting.

In shell_recorder.sh line 248:
                STDOUTCMP=$(echo $line|cut -d ' ' -f2-)
                                 ^-- SC2086: Double quote to prevent globbing and word splitting.

In shell_recorder.sh line 251:
                STDERRCMP=$(echo $line|cut -d ' ' -f2-)
                                 ^-- SC2086: Double quote to prevent globbing and word splitting.

In shell_recorder.sh line 254:
                DIFFCMP=$(echo $line|cut -d ' ' -f2-)
                               ^-- SC2086: Double quote to prevent globbing and word splitting.

In shell_recorder.sh line 258:
                ARG=$(echo $line|cut -d ' ' -f2-)
                           ^-- SC2086: Double quote to prevent globbing and word splitting.

In shell_recorder.sh line 291:
cat "$TMPFILE" | "$KDBCOMMAND" import $Mountpoint 2>/dev/null
    ^-- SC2002: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.
                                      ^-- SC2086: Double quote to prevent globbing and word splitting.

In shell_recorder.sh line 298:
    echo -n "shell_recorder $1 RESULTS: $nbTest test(s) done"
         ^-- SC2039: In POSIX sh, echo flags are undefined.
KurtMi commented 7 years ago

Sry, wrong button

tom-wa commented 7 years ago

@KurtMi can you take a look at #925 ? i have some issues with shellcheck on my system