From 0a2d34be04d72b8982cc2cd488f7e6432d30b40b Mon Sep 17 00:00:00 2001 From: Fedja Beader Date: Sun, 10 Sep 2023 15:58:24 +0200 Subject: trim useless uses of cat --- build/makegprof | 4 ++-- tools/ci/jobs/deheader2.sh | 14 ++++++-------- tools/ci/jobs/imagemagiccheck.sh | 5 ++--- tools/ci/jobs/nsiqcppstyle.sh | 24 +++++++++++------------- tools/ci/jobs/pngcheck.sh | 4 ++-- tools/ci/scripts/init.sh | 14 ++++---------- tools/ci/scripts/runtest.sh | 9 +++------ tools/ci/scripts/updaterepos.sh | 5 ++--- 8 files changed, 32 insertions(+), 47 deletions(-) diff --git a/build/makegprof b/build/makegprof index bfe6922d7..967238b8e 100755 --- a/build/makegprof +++ b/build/makegprof @@ -3,5 +3,5 @@ mv ../run/gmon.out . gprof ../run/bin/manaplus >gprof.txt gprof --inline-file-names ../run/bin/manaplus >gprofi.txt -cat gprof.txt | gprof2dot.py >gprof.dot -cat gprof.dot | dot -Tpng -o gprof.png +gprof2dot.py gprof.dot +dot -Tpng -o gprof.png from ./src/units.cpp" \ > "${LOGFILE2}" -export DATA=$(cat ${LOGFILE2}) -if [[ -n "${DATA}" ]]; then - echo "Wrong include files found" - echo ${DATA} + +if [[ -s "$LOGFILE2" ]]; then + echo "Wrong include files found:" + cat "$LOGFILE2" exit 1 fi diff --git a/tools/ci/jobs/imagemagiccheck.sh b/tools/ci/jobs/imagemagiccheck.sh index 564026f1c..6d2e75060 100755 --- a/tools/ci/jobs/imagemagiccheck.sh +++ b/tools/ci/jobs/imagemagiccheck.sh @@ -10,9 +10,8 @@ rm ${LOG} find -H $DIR -type f -name "*.png" -exec ./tools/ci/scripts/icccheckfile.sh {} \; >${LOG} check_error $? -export RES=$(cat ${LOG}) -if [[ -n "${RES}" ]]; then - echo "Detected icc profiles" +if [[ -s "$LOG" ]]; then + echo "Detected icc profiles:" cat ${LOG} exit 1 fi diff --git a/tools/ci/jobs/nsiqcppstyle.sh b/tools/ci/jobs/nsiqcppstyle.sh index a6db88cc9..d4a5dd449 100755 --- a/tools/ci/jobs/nsiqcppstyle.sh +++ b/tools/ci/jobs/nsiqcppstyle.sh @@ -14,20 +14,18 @@ rm -rf nsiqcppstyle.git -e "/debug/" \ > logs/nsiqcppstyle1.log -cat logs/nsiqcppstyle1.log \ - | grep -v -E \ - -e "gamemodifiers[.]cpp(.+): Incorrect align on long parameter list in front of '(N_|{|})'" \ - -e "graphics_calcImageRect[.]hpp(.+): function [(]calcTileVertexesInline[)] has non named parameter" \ - -e "dye[.]cpp(.+): Do not use goto keyword" \ - -e "item/item[.]cpp(.+): function [(]dragDrop[)] has non named parameter" \ - -e "windowmenu[.]cpp(.+): function [(]addButton[)] has non named parameter" \ - -e "windowmenu[.]cpp(.+): Incorrect align on long parameter list in front of '(.|Visible_true)', it should be aligen in column 15" \ - -e "channeltab[.]h(.+): Incorrect align on long parameter list in front of 'const'" \ - -e "/enums/simpletypes/(.+): function [(]defIntEnum[)] has non named parameter" \ - > "${ERRFILE}" +grep -v -E \ + -e "gamemodifiers[.]cpp(.+): Incorrect align on long parameter list in front of '(N_|{|})'" \ + -e "graphics_calcImageRect[.]hpp(.+): function [(]calcTileVertexesInline[)] has non named parameter" \ + -e "dye[.]cpp(.+): Do not use goto keyword" \ + -e "item/item[.]cpp(.+): function [(]dragDrop[)] has non named parameter" \ + -e "windowmenu[.]cpp(.+): function [(]addButton[)] has non named parameter" \ + -e "windowmenu[.]cpp(.+): Incorrect align on long parameter list in front of '(.|Visible_true)', it should be aligen in column 15" \ + -e "channeltab[.]h(.+): Incorrect align on long parameter list in front of 'const'" \ + -e "/enums/simpletypes/(.+): function [(]defIntEnum[)] has non named parameter" \ + logs/nsiqcppstyle1.log > "${ERRFILE}" -export data=$(cat ${ERRFILE}) -if [ "$DATA" != "" ]; then +if [[ -s "${ERRFILE}" ]]; then echo "Warnings detected" cat ${ERRFILE} fi diff --git a/tools/ci/jobs/pngcheck.sh b/tools/ci/jobs/pngcheck.sh index 2fd0a18d5..e4effc2bf 100755 --- a/tools/ci/jobs/pngcheck.sh +++ b/tools/ci/jobs/pngcheck.sh @@ -11,8 +11,8 @@ rm ${LOG2} find -H . -type f -name "*.png" -exec pngcheck {} \; >${LOG1} grep -v "32-bit RGB+alpha, non-interlaced, " ${LOG1} >${LOG2} -export DATA=$(cat pngcheck2.log) -if [[ -n "${DATA}" ]]; then + +if [[ -s "$LOG2" ]]; then echo "Images must be in 32 bit RGBA and non-interlanced" echo "Wrong images format found:" cat ${LOG2} diff --git a/tools/ci/scripts/init.sh b/tools/ci/scripts/init.sh index 656a4d765..9512e9b66 100755 --- a/tools/ci/scripts/init.sh +++ b/tools/ci/scripts/init.sh @@ -41,10 +41,8 @@ function update_repos { echo "Running from shell. Skipping update repos" return fi - export DATA=$(cat /etc/resolv.conf|grep "nameserver 1.10.100.101") - echo "${DATA}" - if [ "$DATA" != "" ]; - then + + if grep "nameserver 1.10.100.101" /etc/resolv.conf; then echo "Detected local runner" sed -i 's!http://httpredir.debian.org/debian!http://1.10.100.103/debian!' /etc/apt/sources.list sed -i 's!http://deb.debian.org/debian!http://1.10.100.103/debian!' /etc/apt/sources.list @@ -206,9 +204,7 @@ function run_gcov { } function run_check_warnings { - DATA=$(cat $ERRFILE) - if [ "$DATA" != "" ]; - then + if [[ -s "$ERRFILE" ]]; then cat $ERRFILE exit 1 fi @@ -218,9 +214,7 @@ function run_h { rm $ERRFILE echo "$CC -c -x c++ $* $includes */*/*/*/*.h */*/*/*.h */*/*.h */*.h *.h" $CC -c -x c++ $* $includes */*/*/*/*.h */*/*/*.h */*/*.h */*.h *.h 2>$ERRFILE - DATA=$(cat $ERRFILE) - if [ "$DATA" != "" ]; - then + if [[ -s "$ERRFILE" ]]; then cat $ERRFILE exit 1 fi diff --git a/tools/ci/scripts/runtest.sh b/tools/ci/scripts/runtest.sh index 7707a34aa..4b0320fed 100755 --- a/tools/ci/scripts/runtest.sh +++ b/tools/ci/scripts/runtest.sh @@ -74,18 +74,15 @@ function kill_app { } function final_log { - export DATA=$(cat logs/run.log) - if [[ -z "${DATA}" ]]; then + if [[ ! -s logs/run.log ]]; then echo "Error: no output" exit 1 fi cat logs/run.log - export DATA=$(grep "[.]cpp" logs/run.log) - if [[ -n "${DATA}" ]]; then - echo "Error: possible leak detected" - echo "${DATA}" + if grep "[.]cpp" logs/run.log; then + echo "Error: possible leak detected, see above" exit 1 fi } diff --git a/tools/ci/scripts/updaterepos.sh b/tools/ci/scripts/updaterepos.sh index 167898a83..8ac6d6c44 100755 --- a/tools/ci/scripts/updaterepos.sh +++ b/tools/ci/scripts/updaterepos.sh @@ -4,9 +4,8 @@ if [[ "$RUNFROMSHELL" != "" ]]; then echo "Running from shell. Skipping update repos" exit 0 fi -export DATA=$(cat /etc/resolv.conf|grep "nameserver 1.10.100.101") -echo "${DATA}" -if [ "$DATA" != "" ]; then + +if grep "nameserver 1.10.100.101" /etc/resolv.conf; then echo "Detected local runner" sed -i 's!http://httpredir.debian.org/debian!http://1.10.100.103/debian!' /etc/apt/sources.list || true sed -i 's!http://deb.debian.org/debian!http://1.10.100.103/debian!' /etc/apt/sources.list || true -- cgit v1.2.3-60-g2f50