[pacman-dev] [PATCH] repo-add: use wc -c on stdin instead of file to avoid use of cut

Ethan Sommer e5ten.arch at gmail.com
Thu Nov 7 01:23:08 UTC 2019


Redirect file to stdin so wc -c doesn't print a file name that needs to
be stripped.

Signed-off-by: Ethan Sommer <e5ten.arch at gmail.com>
---
 scripts/repo-add.sh.in | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in
index caf1232d..7b2a9edb 100644
--- a/scripts/repo-add.sh.in
+++ b/scripts/repo-add.sh.in
@@ -273,7 +273,7 @@ db_write_entry() {
 			error "$(gettext "Cannot use armored signatures for packages: %s")" "$pkgfile.sig"
 			return 1
 		fi
-		pgpsigsize=$(wc -c "$pkgfile.sig" | cut -d' ' -f1)
+		pgpsigsize=$(wc -c < "$pkgfile.sig")
 		if (( pgpsigsize > 16384 )); then
 			error "$(gettext "Invalid package signature file '%s'.")" "$pkgfile.sig"
 			return 1
@@ -282,7 +282,7 @@ db_write_entry() {
 		pgpsig=$(base64 "$pkgfile.sig" | tr -d '\n')
 	fi
 
-	csize=$(wc -c "$pkgfile" | cut -d' ' -f1)
+	csize=$(wc -c < "$pkgfile")
 
 	# compute checksums
 	msg2 "$(gettext "Computing checksums...")"
-- 
2.23.0


More information about the pacman-dev mailing list