mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 23:24:27 +01:00
Fix shellcheck warnings
This commit is contained in:
committed by
Christian Decker
parent
5a267eb831
commit
b95d3b8f54
@@ -2,11 +2,12 @@
|
|||||||
|
|
||||||
if [ $# -eq 0 ]; then
|
if [ $# -eq 0 ]; then
|
||||||
# With no args, read stdin to scrape compiler output.
|
# With no args, read stdin to scrape compiler output.
|
||||||
set -- $(while read LINE; do
|
# shellcheck disable=SC2046
|
||||||
|
set -- $(while read -r LINE; do
|
||||||
case "$LINE" in
|
case "$LINE" in
|
||||||
*undefined\ reference\ to*)
|
*undefined\ reference\ to*)
|
||||||
LINE=${LINE#*undefined reference to \`}
|
LINE=${LINE#*undefined reference to \`}
|
||||||
echo ${LINE%\'*}
|
echo "${LINE%\'*}"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
continue
|
continue
|
||||||
@@ -17,7 +18,7 @@ fi
|
|||||||
for SYMBOL; do
|
for SYMBOL; do
|
||||||
# If there are multiple declarations, pick first (eg. common/memleak.h
|
# If there are multiple declarations, pick first (eg. common/memleak.h
|
||||||
# has notleak_ as a declaration, and then an inline).
|
# has notleak_ as a declaration, and then an inline).
|
||||||
WHERE=$(grep -nH "^[a-zA-Z0-9_ (),]* [*]*$SYMBOL(" */*.h | head -n1)
|
WHERE=$(grep -nH "^[a-zA-Z0-9_ (),]* [*]*$SYMBOL(" ./*/*.h | head -n1)
|
||||||
if [ x"$WHERE" != x ]; then
|
if [ x"$WHERE" != x ]; then
|
||||||
STUB='\n{ fprintf(stderr, "'$SYMBOL' called!\\n"); abort(); }'
|
STUB='\n{ fprintf(stderr, "'$SYMBOL' called!\\n"); abort(); }'
|
||||||
else
|
else
|
||||||
@@ -29,8 +30,8 @@ for SYMBOL; do
|
|||||||
FILE=${WHERE%%:*}
|
FILE=${WHERE%%:*}
|
||||||
FILE_AND_LINE=${WHERE%:*}
|
FILE_AND_LINE=${WHERE%:*}
|
||||||
LINE=${FILE_AND_LINE#*:}
|
LINE=${FILE_AND_LINE#*:}
|
||||||
END=$(tail -n +$LINE < $FILE | grep -n ';$');
|
END=$(tail -n "+${LINE}" < "$FILE" | grep -n ';$');
|
||||||
NUM=${END%%:*}
|
NUM=${END%%:*}
|
||||||
|
|
||||||
tail -n +$LINE < $FILE | head -n $NUM | sed 's/^extern *//' | sed 's/PRINTF_FMT([^)]*)//' | sed 's/NORETURN//g' | sed 's/,/ UNNEEDED,/g' | sed 's/\([a-z0-9A-Z*_]* [a-z0-9A-Z*_]*\));/\1 UNNEEDED);/' | sed "s/;\$/$STUB/" | sed 's/\s*$//'
|
tail -n "+${LINE}" < "$FILE" | head -n "$NUM" | sed 's/^extern *//' | sed 's/PRINTF_FMT([^)]*)//' | sed 's/NORETURN//g' | sed 's/,/ UNNEEDED,/g' | sed 's/\([a-z0-9A-Z*_]* [a-z0-9A-Z*_]*\));/\1 UNNEEDED);/' | sed "s/;\$/$STUB/" | sed 's/\s*$//'
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -2,6 +2,6 @@
|
|||||||
|
|
||||||
from=${1}
|
from=${1}
|
||||||
to=${2}
|
to=${2}
|
||||||
common=`printf '%s\n%s' "${from}" "${to}" | sed 'N;s/\(.*\).*\n\1.*$/\1/' | sed 's@/[^/]*$@/@'`
|
common=$(printf '%s\n%s' "${from}" "${to}" | sed 'N;s/\(.*\).*\n\1.*$/\1/' | sed 's@/[^/]*$@/@')
|
||||||
prefix=`printf '%s\n' ${from#$common} | sed 's@[^/][^/]*@..@g'`
|
prefix=$(printf '%s\n' "${from#$common}" | sed 's@[^/][^/]*@..@g')
|
||||||
printf '%s\n' "$prefix/${to#$common}"
|
printf '%s\n' "$prefix/${to#$common}"
|
||||||
|
|||||||
@@ -6,34 +6,34 @@
|
|||||||
set -e
|
set -e
|
||||||
FILE="$1"
|
FILE="$1"
|
||||||
|
|
||||||
BASE=/tmp/mocktmp.$$.`echo $@ | tr / _`
|
BASE=/tmp/mocktmp.$$.$(echo "$@" | tr / _)
|
||||||
trap "mv $BASE.old $FILE; rm -f $BASE.*" EXIT
|
trap 'mv $BASE.old $FILE; rm -f $BASE.*' EXIT
|
||||||
|
|
||||||
START=`fgrep -n '/* AUTOGENERATED MOCKS START */' $FILE | cut -d: -f1`
|
START=$(fgrep -n '/* AUTOGENERATED MOCKS START */' "$FILE" | cut -d: -f1)
|
||||||
END=`fgrep -n '/* AUTOGENERATED MOCKS END */' $FILE | cut -d: -f1`
|
END=$(fgrep -n '/* AUTOGENERATED MOCKS END */' "$FILE" | cut -d: -f1)
|
||||||
|
|
||||||
if [ -n "$START" ]; then
|
if [ -n "$START" ]; then
|
||||||
mv $FILE $BASE.old
|
mv "$FILE" "${BASE}.old"
|
||||||
echo $FILE:
|
echo "${FILE}:"
|
||||||
head -n $START $BASE.old > $FILE
|
head -n "$START" "${BASE}.old" > "$FILE"
|
||||||
tail -n +$END $BASE.old >> $FILE
|
tail -n +"$END" "${BASE}.old" >> "$FILE"
|
||||||
# Try to make binary.
|
# Try to make binary.
|
||||||
if ! make `echo $FILE | sed 's/.c$//'` 2> $BASE.err >/dev/null; then
|
if ! make "${FILE/%.c/}" 2> "${BASE}.err" >/dev/null; then
|
||||||
tools/mockup.sh < $BASE.err >> $BASE.stubs
|
tools/mockup.sh < "${BASE}.err" >> "${BASE}.stubs"
|
||||||
# If there are no link errors, maybe compile fail for other reason?
|
# If there are no link errors, maybe compile fail for other reason?
|
||||||
if ! fgrep -q 'Generated stub for' $BASE.stubs; then
|
if ! fgrep -q 'Generated stub for' "${BASE}.stubs"; then
|
||||||
cat $BASE.err
|
cat "${BASE}.err"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
sed -n 's,.*Generated stub for \(.*\) .*,\t\1,p' < $BASE.stubs
|
sed -n 's,.*Generated stub for \(.*\) .*,\t\1,p' < "${BASE}.stubs"
|
||||||
head -n $START $BASE.old > $FILE
|
head -n "$START" "${BASE}.old" > "$FILE"
|
||||||
cat $BASE.stubs >> $FILE
|
cat "${BASE}.stubs" >> "$FILE"
|
||||||
tail -n +$END $BASE.old >> $FILE
|
tail -n +"$END" "${BASE}.old" >> "$FILE"
|
||||||
else
|
else
|
||||||
echo "...build succeeded without stubs"
|
echo "...build succeeded without stubs"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# All good.
|
# All good.
|
||||||
rm -f $BASE.*
|
rm -f "$BASE".*
|
||||||
trap "" EXIT
|
trap "" EXIT
|
||||||
|
|||||||
Reference in New Issue
Block a user