mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 01:43:36 +01:00
2e4a58efac
And make errors gcc-style, so emacs can jump through the automatically. ``` In devtools/reduce-includes.sh line 21: echo -n "-$LINE" ^-- SC3037 (warning): In POSIX sh, echo flags are undefined. In devtools/reduce-includes.sh line 25: echo -n "." ^-- SC3037 (warning): In POSIX sh, echo flags are undefined. In tools/rel.sh line 6: prefix=$(printf '%s\n' "${from#$common}" | sed 's@[^/][^/]*@..@g') ^-----^ SC2295 (info): Expansions inside ${..} need to be quoted separately, otherwise they match as patterns. Did you mean: prefix=$(printf '%s\n' "${from#"$common"}" | sed 's@[^/][^/]*@..@g') In tools/rel.sh line 7: printf '%s\n' "$prefix/${to#$common}" ^-----^ SC2295 (info): Expansions inside ${..} need to be quoted separately, otherwise they match as patterns. Did you mean: printf '%s\n' "$prefix/${to#"$common"}" For more information: https://www.shellcheck.net/wiki/SC3037 -- In POSIX sh, echo flags are undef... https://www.shellcheck.net/wiki/SC2295 -- Expansions inside ${..} need to b... make: *** [Makefile:553: check-shellcheck] Error 123 ``` Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
32 lines
735 B
Bash
Executable File
32 lines
735 B
Bash
Executable File
#! /bin/sh -e
|
|
|
|
if [ $# -lt 1 ]; then
|
|
echo "Usage: $0 <cfilepath>...; removes #includes one at a time and checks compile" >&2
|
|
exit 1
|
|
fi
|
|
|
|
CCMD=$(make show-flags | sed -n 's/CC://p')
|
|
for file; do
|
|
i=1
|
|
echo "$file":
|
|
while true; do
|
|
# Don't eliminate config.h includes!
|
|
LINE="$(grep '^#include <' "$file" | grep -v '[<"]config.h[">]' | tail -n +$i | head -n1)"
|
|
[ -n "$LINE" ] || break
|
|
# Make sure even headers end in .c
|
|
grep -F -v "$LINE" "$file" > "$file".c
|
|
|
|
if $CCMD /tmp/out.$$.o "$file".c 2>/dev/null; then
|
|
printf "%s" "-$LINE"
|
|
mv "$file".c "$file"
|
|
else
|
|
# shellcheck disable=SC2039,SC3037
|
|
printf "."
|
|
rm -f "$file".c
|
|
i=$((i + 1))
|
|
fi
|
|
rm -f /tmp/out.$$.o
|
|
done
|
|
echo
|
|
done
|