]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
check-format-commit: call fewer unneeded processes
authorBeat Bolli <dev@drbeat.li>
Sat, 17 Aug 2024 15:34:14 +0000 (17:34 +0200)
committerDr. David von Oheimb <dev@ddvo.net>
Sat, 26 Oct 2024 17:35:43 +0000 (19:35 +0200)
`wc` does not output a file name if the input is stdin.

`awk` reads its file argument; there's no need for `cat`.

`sort -u` outputs unique lines. It should be supported on all platforms,
as it's specified by POSIX.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25562)

(cherry picked from commit 0d6544cdf845f7950c50680059c976cb507b6e45)

util/check-format-commit.sh

index 93f5c22bfcbbad216913b0b730ec68679882f5e5..cf958923fa0d76aac181c2c3f12ead7506676567 100755 (executable)
@@ -94,7 +94,7 @@ do
     grep "$i " $TEMPDIR/ranges.txt >> $TEMPDIR/ranges.filter || true
 done
 cp $TEMPDIR/ranges.filter $TEMPDIR/ranges.txt
-REMAINING_FILES=$(wc -l $TEMPDIR/ranges.filter | awk '{print $1}')
+REMAINING_FILES=$(wc -l <$TEMPDIR/ranges.filter)
 if [ $REMAINING_FILES -eq 0 ]
 then
     echo "This commit has no files that require checking"
@@ -107,7 +107,7 @@ fi
 # to $TEMPDIR/check-format.  This give us the full file to run
 # check-format.pl on with line numbers matching the ranges in the
 # $TEMPDIR/ranges.txt file
-for j in $(cat $TEMPDIR/ranges.txt | awk '{print $1}' | sort | uniq)
+for j in $(awk '{print $1}' $TEMPDIR/ranges.txt | sort -u)
 do
     FDIR=$(dirname $j)
     mkdir -p $TEMPDIR/check-format/$FDIR
@@ -115,7 +115,7 @@ do
 done
 
 # Now for each file in $TEMPDIR/ranges.txt, run check-format.pl
-for j in $(cat $TEMPDIR/ranges.txt | awk '{print $1}' | sort | uniq)
+for j in $(awk '{print $1}' $TEMPDIR/ranges.txt | sort -u)
 do
     range_start=()
     range_end=()