fff-hoods: let sha256sum read file directly

This removes two useless cat as found by shellcheck:

  sumnew=$(cat "$hoodfiletmp" 2>/dev/null | sha256sum | cut -f1 -d " ")
               ^-- SC2002: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.

While not functionally relevant in our case, note that

  cat <non-existant-file> | sha256sum

actually returns a hash code, while

  sha256sum <non-existant-file>

does not return anything on stdout.

Since we check the existance of $hoodfiletmp before calling sha256sum,
though, we always have a hash value for at least one file, so two empty
checksum won't happen at that point.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Reviewed-by: Fabian Bläse <fabian@blaese.de>
This commit is contained in:
Adrian Schmutzler 2020-08-01 01:28:33 +02:00
parent b5563caa23
commit a157f413d4
2 changed files with 3 additions and 3 deletions

View File

@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=fff-hoods
PKG_RELEASE:=13
PKG_RELEASE:=14
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)

View File

@ -78,8 +78,8 @@ if [ -s "$hoodfiletmp" ]; then
# https://pw.freifunk-franken.de/patch/205/
# but without signature, every hood file we get is valid!
sumnew=$(cat "$hoodfiletmp" 2>/dev/null | sha256sum | cut -f1 -d " ")
sumold=$(cat "$hoodfileref" 2>/dev/null | sha256sum | cut -f1 -d " ")
sumnew=$(sha256sum "$hoodfiletmp" 2>/dev/null | cut -f1 -d " ")
sumold=$(sha256sum "$hoodfileref" 2>/dev/null | cut -f1 -d " ")
json_load "$(cat "$hoodfiletmp")"