Skip to content

Commit f46a9e3

Browse files
authored
fixed/excluded some shellcheck warnings and actually fail the build when something is found (cppcheck-opensource#3068)
1 parent 2cb2012 commit f46a9e3

10 files changed

Lines changed: 34 additions & 37 deletions

File tree

.github/workflows/scriptcheck.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
2727
- name: run Shellcheck
2828
run: |
29-
find . -name "*.sh" | xargs shellcheck || true
29+
find . -name "*.sh" | xargs shellcheck --exclude SC2002,SC2013,SC2034,SC2035,SC2043,SC2046,SC2086,SC2089,SC2090,SC2129,SC2211,SC2231
3030
3131
- name: run pylint
3232
run: |

cve-test-suite/download.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
echo "CVE" > cve.txt
55

6-
for i in `seq 1 20`;
6+
for i in $(seq 1 20);
77
do
88
echo "page $i"
99
# CVE 119 issues:

man/build-pdf.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pandoc $1.md -o $1.pdf -s --number-sections --toc \
2525
--listings \
2626
-f markdown \
2727
-V mainfont="$MainFont" \
28-
-V monofont="$Consolas" \
28+
-V monofont="$MonoFont" \
2929
-V geometry:a4paper \
3030
-V geometry:margin=2.4cm \
3131
-V subparagraph \

test/cfg/generate-cfg-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
cd ~/cppcheck
2+
cd ~/cppcheck || exit 1
33
make generate_cfg_tests
44
./generate_cfg_tests cfg/avr.cfg > test/cfg/generated-cfg-tests-avr.cpp
55
./generate_cfg_tests cfg/bsd.cfg > test/cfg/generated-cfg-tests-bsd.cpp

test/cfg/runtests.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -401,11 +401,7 @@ set -e
401401
if [ $PKGCONFIG_RETURNCODE -ne 0 ]; then
402402
echo "pkg-config needed to retrieve cppunit configuration is not available, skipping syntax check."
403403
else
404-
set +e
405-
CPPUNIT=$(pkg-config cppunit)
406-
CPPUNIT_RETURNCODE=$?
407-
set -e
408-
if [ $CPPUNIT_RETURNCODE -ne 0 ]; then
404+
if pkg-config cppunit; then
409405
echo "cppunit not found, skipping syntax check for cppunit"
410406
else
411407
echo "cppunit found, checking syntax with ${CXX} now."

test/synthetic/run-clang.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/bin/bash
12
~/llvm/build/bin/clang -cc1 -analyze -analyzer-checker=alpha.security controlflow.c data.c functions.c 2>&1 /dev/null | grep warning
23
~/llvm/build/bin/clang -cc1 -analyze -analyzer-checker=alpha.security,core ub.c 2>&1 /dev/null | grep warning
34

tools/daca2-logs2git.sh

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ base_url="http://cppcheck.sourceforge.net/devinfo/daca2-report/"
88
echo ${base_url}daca2.html
99

1010

11-
for site in `curl -s --compressed ${base_url}daca2.html | grep "^<tr" | grep -o "\".*\"" | sed s/\"//g` ; do
11+
for site in $(curl -s --compressed ${base_url}daca2.html | grep "^<tr" | grep -o "\".*\"" | sed s/\"//g) ; do
1212
echo ${site} ; curl -s --compressed ${base_url}${site} | sort -n --parallel=4 | sed 's/^ *//; s/ *$//; /^$/d; s/^M$//; s/\r$//' | sed -e 's/\[[0-9][0-9]:[0-9][0-9]\]$//' | sed '/^$/d' | sed 's/\&amp\;/\&/g; s/&lt;/</g; s/&gt;/>/g;' > ${site}
1313
done
1414

@@ -24,37 +24,37 @@ grep "^-.*" /tmp/daca_tmp_diff > /tmp/daca_tmp_minus
2424

2525

2626

27-
plus_glob=`wc -l /tmp/daca_tmp_plus | cut -d' ' -f1`
27+
plus_glob=$(wc -l /tmp/daca_tmp_plus | cut -d' ' -f1)
2828

29-
plus_error=`grep -c ":\ \(inconclusive\ \)\?error: " /tmp/daca_tmp_plus`
30-
plus_warning=`grep -c ":\ \(inconclusive\ \)\?warning: " /tmp/daca_tmp_plus`
31-
plus_style=`grep -c ":\ \(inconclusive\ \)\?style: " /tmp/daca_tmp_plus`
32-
plus_performance=`grep -c ":\ \(inconclusive\ \)\?performance: " /tmp/daca_tmp_plus`
33-
plus_portability=`grep -c ":\ \(inconclusive\ \)\?portability: " /tmp/daca_tmp_plus`
34-
#plus_information=`grep -c "]: (information)" /tmp/daca_tmp_plus`
35-
plus_crash=`grep -c "\ Crash?$" /tmp/daca_tmp_plus`
36-
plus_varid=`grep -c "called with varid 0\." /tmp/daca_tmp_plus`
29+
plus_error=$(grep -c ":\ \(inconclusive\ \)\?error: " /tmp/daca_tmp_plus)
30+
plus_warning=$(grep -c ":\ \(inconclusive\ \)\?warning: " /tmp/daca_tmp_plus)
31+
plus_style=$(grep -c ":\ \(inconclusive\ \)\?style: " /tmp/daca_tmp_plus)
32+
plus_performance=$(grep -c ":\ \(inconclusive\ \)\?performance: " /tmp/daca_tmp_plus)
33+
plus_portability=$(grep -c ":\ \(inconclusive\ \)\?portability: " /tmp/daca_tmp_plus)
34+
#plus_information=$(grep -c "]: (information)" /tmp/daca_tmp_plus)
35+
plus_crash=$(grep -c "\ Crash?$" /tmp/daca_tmp_plus)
36+
plus_varid=$(grep -c "called with varid 0\." /tmp/daca_tmp_plus)
3737

3838

39-
minus_glob=`wc -l /tmp/daca_tmp_minus | cut -d' ' -f1`
39+
minus_glob=$(wc -l /tmp/daca_tmp_minus | cut -d' ' -f1)
4040

41-
minus_error=`grep -c ":\ \(inconclusive\ \)\?error: " /tmp/daca_tmp_minus`
42-
minus_warning=`grep -c ":\ \(inconclusive\ \)\?warning: " /tmp/daca_tmp_minus`
43-
minus_style=`grep -c ":\ \(inconclusive\ \)\?style: " /tmp/daca_tmp_minus`
44-
minus_performance=`grep -c ":\ \(inconclusive\ \)\?performance: " /tmp/daca_tmp_minus`
45-
minus_portability=`grep -c ":\ \(inconclusive\ \)\?portability: " /tmp/daca_tmp_minus`
46-
#minus_information=`grep -c "]: (information)" /tmp/daca_tmp_minus`
47-
minus_crash=`grep -c "\ Crash?$" /tmp/daca_tmp_minus`
48-
minus_varid=`grep -c "called with varid 0\." /tmp/daca_tmp_minus`
41+
minus_error=$(grep -c ":\ \(inconclusive\ \)\?error: " /tmp/daca_tmp_minus)
42+
minus_warning=$(grep -c ":\ \(inconclusive\ \)\?warning: " /tmp/daca_tmp_minus)
43+
minus_style=$(grep -c ":\ \(inconclusive\ \)\?style: " /tmp/daca_tmp_minus)
44+
minus_performance=$(grep -c ":\ \(inconclusive\ \)\?performance: " /tmp/daca_tmp_minus)
45+
minus_portability=$(grep -c ":\ \(inconclusive\ \)\?portability: " /tmp/daca_tmp_minus)
46+
#minus_information=$(grep -c "]: (information)" /tmp/daca_tmp_minus)
47+
minus_crash=$(grep -c "\ Crash?$" /tmp/daca_tmp_minus)
48+
minus_varid=$(grep -c "called with varid 0\." /tmp/daca_tmp_minus)
4949

5050

5151

52-
files=`git ls-files`
52+
files=$(git ls-files)
5353

54-
ID_stats=`awk '{ print $NF }' $files | grep "^\[.*\]$" | sort -n | uniq --count | sort -n`
54+
ID_stats=$(awk '{ print $NF }' $files | grep "^\[.*\]$" | sort -n | uniq --count | sort -n)
5555

56-
echo "Update `date`" >> /tmp/daca_msg
57-
echo "Updated: `git status --porcelain | grep daca | cut -d' ' -f3 | sed s/daca2-// | sed s/\.html// | tr '\n' ' '`" >> /tmp/daca_msg
56+
echo "Update $(date)" >> /tmp/daca_msg
57+
echo "Updated: $(git status --porcelain | grep daca | cut -d' ' -f3 | sed s/daca2-// | sed s/\.html// | tr '\n' ' ')" >> /tmp/daca_msg
5858
echo "all: new: $plus_glob gone: $minus_glob = $((plus_glob-minus_glob))" >> /tmp/daca_msg
5959
echo "error: new: $plus_error gone: $minus_error = $((plus_error-minus_error))" >> /tmp/daca_msg
6060
echo "warning: new: $plus_warning gone: $minus_warning = $((plus_warning-minus_warning))" >> /tmp/daca_msg
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/bin/bash
22

3-
cd ~/cppcheck
3+
cd ~/cppcheck || exit 1
44
rm -rf test1
55
python tools/extracttests.py --code=test1 test/testleakautovar.cpp
6-
cd ~/cppcheck/test1
6+
cd ~/cppcheck/test1 || exit 1
77
~/cppcheck/tools/run_more_tests.sh
88

tools/run-coverity.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
PATH=$PATH:/home/danielmarjamaki/cov-analysis-linux64-2019.03/bin
3-
cd /home/danielmarjamaki/cppcheck-devinfo
3+
cd /home/danielmarjamaki/cppcheck-devinfo || exit 1
44
git pull
55

66
echo Analyze
@@ -15,7 +15,7 @@ curl --insecure \
1515
--form token=e74RRnWR6BVsn5LKdclfcA \
1616
--form email=daniel.marjamaki@gmail.com \
1717
--form file=@cppcheck.tgz \
18-
--form version=`git log -1 --format=oneline | sed -r 's/([a-f0-9]{7}).*/\1/'` \
18+
--form version=$(git log -1 --format=oneline | sed -r 's/([a-f0-9]{7}).*/\1/') \
1919
--form description="Development" \
2020
https://scan.coverity.com/builds?project=cppcheck
2121

webreport.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ mv coverage_report devinfo/
1010
doxygen 2> devinfo/doxygen-errors.txt
1111
mv doxyoutput/html devinfo/doxyoutput
1212

13-
cd addons
13+
cd addons || exit 1
1414
doxygen cppcheckdata.doxyfile
1515
mv html ../devinfo/cppcheckdata
1616
cd ..

0 commit comments

Comments
 (0)