mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-10-01 06:21:56 -09:00
utils/config: fix shellcheck errors
In utils/config line 54:
ARG="`echo $ARG | tr a-z- A-Z_`"
^------------------------^ SC2006: Use $(...) notation instead of legacy backticked `...`.
^--^ SC2086: Double quote to prevent globbing and word splitting.
Did you mean:
ARG="$(echo "$ARG" | tr a-z- A-Z_)"
In utils/config line 87:
local tmpfile="$infile.swp"
^-----^ SC2034: tmpfile appears unused. Verify use (or export if used externally).
In utils/config line 182:
if [ $? != 0 ] ; then
^-- SC2181: Check exit code directly with e.g. 'if mycmd;', not indirectly with $?.
For more information:
https://www.shellcheck.net/wiki/SC2034 -- tmpfile appears unused. Verify us...
https://www.shellcheck.net/wiki/SC2086 -- Double quote to prevent globbing ...
https://www.shellcheck.net/wiki/SC2006 -- Use $(...) notation instead of le...
The suggestions from shellcheck can be applied.
The unused variable tmpfile in fact occurs in several functions, all of
them can be removed.
For the check exit code, the condition is swapped to avoid negative
logic.
Signed-off-by: Arnout Vandecappelle <arnout@mind.be>
This commit is contained in:
12
utils/config
12
utils/config
@@ -51,7 +51,7 @@ checkarg() {
|
|||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
if [ "$MUNGE_CASE" = "yes" ] ; then
|
if [ "$MUNGE_CASE" = "yes" ] ; then
|
||||||
ARG="`echo $ARG | tr a-z- A-Z_`"
|
ARG="$(echo "$ARG" | tr a-z- A-Z_)"
|
||||||
fi
|
fi
|
||||||
case "$ARG" in
|
case "$ARG" in
|
||||||
${BR2_PREFIX}*)
|
${BR2_PREFIX}*)
|
||||||
@@ -64,7 +64,6 @@ txt_append() {
|
|||||||
local anchor="$1"
|
local anchor="$1"
|
||||||
local insert="$2"
|
local insert="$2"
|
||||||
local infile="$3"
|
local infile="$3"
|
||||||
local tmpfile="$infile.swp"
|
|
||||||
|
|
||||||
# sed append cmd: 'a\' + newline + text + newline
|
# sed append cmd: 'a\' + newline + text + newline
|
||||||
cmd="$(printf "a\\%b$insert" "\n")"
|
cmd="$(printf "a\\%b$insert" "\n")"
|
||||||
@@ -76,7 +75,6 @@ txt_subst() {
|
|||||||
local before="$1"
|
local before="$1"
|
||||||
local after="$2"
|
local after="$2"
|
||||||
local infile="$3"
|
local infile="$3"
|
||||||
local tmpfile="$infile.swp"
|
|
||||||
|
|
||||||
sed -i -e "s:$before:$after:" "$infile"
|
sed -i -e "s:$before:$after:" "$infile"
|
||||||
}
|
}
|
||||||
@@ -84,7 +82,6 @@ txt_subst() {
|
|||||||
txt_delete() {
|
txt_delete() {
|
||||||
local text="$1"
|
local text="$1"
|
||||||
local infile="$2"
|
local infile="$2"
|
||||||
local tmpfile="$infile.swp"
|
|
||||||
|
|
||||||
sed -i -e "/$text/d" "$infile"
|
sed -i -e "/$text/d" "$infile"
|
||||||
}
|
}
|
||||||
@@ -178,15 +175,14 @@ while [ "$1" != "" ] ; do
|
|||||||
if grep -q "# ${BR2_PREFIX}$ARG is not set" $FN ; then
|
if grep -q "# ${BR2_PREFIX}$ARG is not set" $FN ; then
|
||||||
echo n
|
echo n
|
||||||
else
|
else
|
||||||
V="$(grep "^${BR2_PREFIX}$ARG=" $FN)"
|
if V="$(grep "^${BR2_PREFIX}$ARG=" $FN)"; then
|
||||||
if [ $? != 0 ] ; then
|
|
||||||
echo undef
|
|
||||||
else
|
|
||||||
V="${V/#${BR2_PREFIX}$ARG=/}"
|
V="${V/#${BR2_PREFIX}$ARG=/}"
|
||||||
V="${V/#\"/}"
|
V="${V/#\"/}"
|
||||||
V="${V/%\"/}"
|
V="${V/%\"/}"
|
||||||
V="${V//\\\"/\"}"
|
V="${V//\\\"/\"}"
|
||||||
echo "${V}"
|
echo "${V}"
|
||||||
|
else
|
||||||
|
echo undef
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|||||||
Reference in New Issue
Block a user