Hi,
"shellcheck -e SC2006" (to silence complains concerning ``) suggests double
quotes around "$file"
sum_from_file=`dd if=$file bs=2048 count=$blocks | $checksummer | head -1 |
awk '{print $1}'`
Indeed. Some variable evaluations slipped through unquoted.
Two others are intentionally capable of becomming zero to many words and
as safe as can be without excluding some old shells:
grep $update_v
| $checksummer |
I dimly remember that $(...) did not work on one of the tested machines
back in 2011. I don't see hard reasons to avoid it in the particular
use cases in check_debian_iso. So i keep it as is and hope that the old
tests are not invalidated by the other changes.
shellcheck on Debian 12 also complains about SC2197 (fgrep) and
SC2003 (expr), which are normal for an old script. They are not really
wrong. So i keep them for the same reason as the backticks and the
unquoted variables.
I prepared a new version and put it into libisoburn's git:
https://dev.lovelyhq.com/libburnia/libisoburn/raw/branch/master/xorriso-dd-target/check_debian_iso
PGP signature file:
https://dev.lovelyhq.com/libburnia/libisoburn/raw/branch/master/xorriso-dd-target/check_debian_iso.asc
------------------------------------------------------------------------
--- a/check_debian_iso 2011-12-17 19:33:50.000000000 +0100
+++ b/check_debian_iso 2024-09-04 14:19:43.987633803 +0200
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# check_debian_iso, copyright 2011 Thomas Schmitt <***@gmx.net>
+# check_debian_iso, copyright 2011,2024 Thomas Schmitt <***@gmx.net>
# License: GPLv2 or later
# Tested on: Little-endian GNU/Linux with bash
# Little-endian FreeBSD-8 with sh and "md5 -q"
@@ -145,12 +145,12 @@ fi
# The two 16 bit numbers, which are of the appropriate byte sex,
# get combined to a 32 bit number.
-blocks=`expr $lo + $hi '*' 65536`
+blocks=`expr "$lo" + "$hi" '*' 65536`
echo "Piping $blocks blocks of '$file' through '$checksummer'" >&2
echo "to verify checksum list item '$name_from_list'." >&2
-sum_from_file=`dd if=$file bs=2048 count=$blocks | $checksummer | head -1 | awk '{print $1}'`
+sum_from_file=`dd if="$file" bs=2048 count="$blocks" | $checksummer | head -1 | awk '{print $1}'`
if test "$sum_from_list" = "$sum_from_file"
then
------------------------------------------------------------------------
Regrettably the version in
https://people.debian.org/~danchev/debian-iso/
is out of my reach. I will have to ask debian-cd to adopt the new one.
(For now it is only the user who can shoot the own foot by submitting
a hopeless image name.)
Should the command line be prefixed with "#" instead since regular user can
not do it?
Indeed. I had a script enable rw before copying the test ISO to the USB
stick. So i did not notice that superuser authority is needed.
On the other hand
$ sudo mount "$path_to_image_or_usb_device" "$mountpoint"
can be done as a regular user (an alternative is pmount)
udisksctl mount -b /dev/sdb1
I really dislike udisks.
"d-live 12.7.0 kd amd64" is a bit weird from my point of view for the
mountpoint, but unfortunately udisksd logic is hardcoded.
That's one of my reasons.
In general i think that "sudo" makes clearer what obstacle needs to be
surpassed.
Thanks for the review.
Have a nice day :)
Thomas