MyAssetBoard/coinboard-webapp

View on GitHub
conf/onion/turnmeon.sh

Summary

Maintainability
Test Coverage

Declare and assign separately to avoid masking return values.
Open

export IP=$(ip -o -4 a s wlan0 | awk '{ print $4 }' | cut -d/ -f1)
Severity: Minor
Found in conf/onion/turnmeon.sh by shellcheck

Declare and assign separately to avoid masking return values.

Problematic code:

export foo="$(mycmd)"

Correct code:

foo=$(mycmd)
export foo

Rationale:

In the original code, the return value of mycmd is ignored, and export will instead always return true. This may prevent conditionals, set -e and traps from working correctly.

When first marked for export and assigned separately, the return value of the assignment will be that of mycmd. This avoids the problem.

Exceptions:

If you intend to ignore the return value of an assignment, you can either ignore this warning or use

foo=$(mycmd) || true
export foo

Shellcheck does not warn about export foo=bar because bar is a literal and not a command substitution with an independent return value. It also does not warn about local -r foo=$(cmd), where declaration and assignment must be in the same command.

Notice

Original content from the ShellCheck https://github.com/koalaman/shellcheck/wiki.

echo won't expand escape sequences. Consider printf.
Open

echo "\n\tOptions :"
Severity: Minor
Found in conf/onion/turnmeon.sh by shellcheck

echo won't expand escape sequences. Consider printf.

Problematic code:

echo "Name:\t$value"

Correct code:

printf "Name:\t%s\n" "$value"

Rationale:

Backslash escapes like \t and \n are not expanded by echo, and become literal backslash-t, backslash-n.

printf does expand these sequences, and should be used instead.

Other, non-portable methods include echo -e '\t' and echo $'\t'. ShellCheck will warn if this is used in a script with shebang #!/bin/sh.

If you actually wanted a literal backslash-t, use

echo "\\t"

Exceptions

None

Notice

Original content from the ShellCheck https://github.com/koalaman/shellcheck/wiki.

There are no issues that match your filters.

Category
Status