Added option -dummy_force

This commit is contained in:
Thomas Schmitt 2019-11-30 18:35:31 +01:00
parent 69ce40b6d4
commit 099d24f740

View File

@ -103,6 +103,10 @@ print_usage() {
echo " advised device names to get a real write run."
echo " -dummy Report the -DO_WRITE actions but do not perform"
echo " them."
echo " -dummy_force If a single device name is given, do a run of"
echo " -dummy -DO_WRITE even against the advice of"
echo " this program. This probably shows you ways to"
echo " shoot your own foot."
echo " -help Print this text to stdout and then end the program."
echo "Examples:"
echo " $0 -with_sudo -list_all"
@ -133,6 +137,7 @@ reset_job() {
image_file=
do_write=
dummy_run=
dummy_force=
do_plug_test=
# Status
@ -194,6 +199,11 @@ arg_interpreter() {
elif test "$i" = "-dummy"
then
dummy_run=y
elif test "$i" = "-dummy_force"
then
dummy_run=y
do_write=y
dummy_force=y
elif test "$i" = "-DO_WRITE"
then
do_write=y
@ -501,7 +511,11 @@ write_image() {
echo "No executable program umount found in: $sudo_x_dir_list" >&2
return 6
fi
if test -n "$dummy_run"
if test -n "$dummy_force"
then
echo "AGAINST THE ADVICE BY THIS PROGRAM, a daring user could do:"
dummy_run=y
elif test -n "$dummy_run"
then
echo "Would do if not -dummy:"
fi
@ -550,6 +564,10 @@ write_image() {
echo "--- not activated yet ---"
fi
if test -n "$dummy_force"
then
echo "BE SMART. BE CAUTIOUS. BEWARE."
fi
return 0
}
@ -575,8 +593,26 @@ then
with_vendor_model=
show_reasons=
candidates=$(list_devices | tr '\n\r' ' ')
num=$(echo $candidates | wc -w)
if test "$num" -eq 1
num_cand=$(echo $candidates | wc -w)
num_devs=$(echo $devs| wc -w)
if test -n "$dummy_force" -a "$num_devs" -ne 1
then
echo "SORRY: Refusing -dummy_force with not exactly one device." >&2
exit 10
fi
if test -n "$dummy_force" -a -n "$dummy_run" -a "$num_cand" -ne 1
then
# -dummy_force in a situation where the program would normally refuse
echo "Overriding any advice because of -dummy_force"
candidates="$devs"
num_cand=1
elif test -n "$dummy_force"
then
# Downgrade -dummy_force to -dummy in order to avoid the ugly warning
dummy_force=
dummy_run=y
fi
if test "$num_cand" -eq 1
then
if test -n "$image_file"
then
@ -598,7 +634,7 @@ then
echo "Would write to /dev/$candidates if an -image_file were given." >&2
exit 0
fi
elif test "$num" -gt 1
elif test "$num_cand" -gt 1
then
echo "WILL NOT WRITE ! More than one candidate found for target device:" >&2
show_reasons=y