Skip to content

use shellcheck #38

Open
Open
@nathanlynch

Description

@nathanlynch

powerpc-utils contains several non-trivial shell scripts which contain basic errors and bad practices:

In ofpathname line 266:
        if [ $? -eq 0 ]; then
             ^-- SC2181: Check exit code directly with e.g. 'if mycmd;', not indirectly with $?.


In ofpathname line 271:
    if [ -f $PWD/devpath ]; then
            ^--^ SC2086: Double quote to prevent globbing and word splitting.

Did you mean: 
    if [ -f "$PWD"/devpath ]; then


In ofpathname line 272:
	echo `$CAT $PWD/devpath`
             ^-----------------^ SC2046: Quote this to prevent word splitting.
             ^-----------------^ SC2005: Useless echo? Instead of 'echo $(cmd)', just use 'cmd'.
             ^-----------------^ SC2006: Use $(...) notation instead of legacy backticked `...`.
                   ^--^ SC2086: Double quote to prevent globbing and word splitting.

Did you mean: 
	echo $($CAT "$PWD"/devpath)


In ofpathname line 298:
    cd $start_dir
    ^-----------^ SC2164: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.
       ^--------^ SC2086: Double quote to prevent globbing and word splitting.

Did you mean: 
    cd "$start_dir" || exit

We should use shellcheck, perhaps as part of make check or a commit hook, in order to bring up the quality of the scripts.
https://www.shellcheck.net/

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions