Added option -dummy_force
This commit is contained in:
parent
69ce40b6d4
commit
099d24f740
@ -103,6 +103,10 @@ print_usage() {
|
|||||||
echo " advised device names to get a real write run."
|
echo " advised device names to get a real write run."
|
||||||
echo " -dummy Report the -DO_WRITE actions but do not perform"
|
echo " -dummy Report the -DO_WRITE actions but do not perform"
|
||||||
echo " them."
|
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 " -help Print this text to stdout and then end the program."
|
||||||
echo "Examples:"
|
echo "Examples:"
|
||||||
echo " $0 -with_sudo -list_all"
|
echo " $0 -with_sudo -list_all"
|
||||||
@ -133,6 +137,7 @@ reset_job() {
|
|||||||
image_file=
|
image_file=
|
||||||
do_write=
|
do_write=
|
||||||
dummy_run=
|
dummy_run=
|
||||||
|
dummy_force=
|
||||||
do_plug_test=
|
do_plug_test=
|
||||||
|
|
||||||
# Status
|
# Status
|
||||||
@ -194,6 +199,11 @@ arg_interpreter() {
|
|||||||
elif test "$i" = "-dummy"
|
elif test "$i" = "-dummy"
|
||||||
then
|
then
|
||||||
dummy_run=y
|
dummy_run=y
|
||||||
|
elif test "$i" = "-dummy_force"
|
||||||
|
then
|
||||||
|
dummy_run=y
|
||||||
|
do_write=y
|
||||||
|
dummy_force=y
|
||||||
elif test "$i" = "-DO_WRITE"
|
elif test "$i" = "-DO_WRITE"
|
||||||
then
|
then
|
||||||
do_write=y
|
do_write=y
|
||||||
@ -501,7 +511,11 @@ write_image() {
|
|||||||
echo "No executable program umount found in: $sudo_x_dir_list" >&2
|
echo "No executable program umount found in: $sudo_x_dir_list" >&2
|
||||||
return 6
|
return 6
|
||||||
fi
|
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
|
then
|
||||||
echo "Would do if not -dummy:"
|
echo "Would do if not -dummy:"
|
||||||
fi
|
fi
|
||||||
@ -550,6 +564,10 @@ write_image() {
|
|||||||
echo "--- not activated yet ---"
|
echo "--- not activated yet ---"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if test -n "$dummy_force"
|
||||||
|
then
|
||||||
|
echo "BE SMART. BE CAUTIOUS. BEWARE."
|
||||||
|
fi
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -575,8 +593,26 @@ then
|
|||||||
with_vendor_model=
|
with_vendor_model=
|
||||||
show_reasons=
|
show_reasons=
|
||||||
candidates=$(list_devices | tr '\n\r' ' ')
|
candidates=$(list_devices | tr '\n\r' ' ')
|
||||||
num=$(echo $candidates | wc -w)
|
num_cand=$(echo $candidates | wc -w)
|
||||||
if test "$num" -eq 1
|
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
|
then
|
||||||
if test -n "$image_file"
|
if test -n "$image_file"
|
||||||
then
|
then
|
||||||
@ -598,7 +634,7 @@ then
|
|||||||
echo "Would write to /dev/$candidates if an -image_file were given." >&2
|
echo "Would write to /dev/$candidates if an -image_file were given." >&2
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
elif test "$num" -gt 1
|
elif test "$num_cand" -gt 1
|
||||||
then
|
then
|
||||||
echo "WILL NOT WRITE ! More than one candidate found for target device:" >&2
|
echo "WILL NOT WRITE ! More than one candidate found for target device:" >&2
|
||||||
show_reasons=y
|
show_reasons=y
|
||||||
|
Loading…
Reference in New Issue
Block a user