summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2021-01-08 13:34:41 +0100
committerNatanael Copa <ncopa@alpinelinux.org>2021-01-08 13:34:41 +0100
commitbc4fff32768c6a44db454f2084dd60b860749746 (patch)
tree4145bf7c74b0f78aea4eceea5ec07ee557cb1b53
parentc9eb98a39e2ce65014f4d15fe1572fc611c557e3 (diff)
downloadalpine-conf-bc4fff32768c6a44db454f2084dd60b860749746.zip
dasd-functions.sh: use ask/ask_yesno/$resp for consistency
-rw-r--r--dasd-functions.sh.in21
1 files changed, 9 insertions, 12 deletions
diff --git a/dasd-functions.sh.in b/dasd-functions.sh.in
index ae25a79..e71f098 100644
--- a/dasd-functions.sh.in
+++ b/dasd-functions.sh.in
@@ -4,15 +4,13 @@ eckd_dasd=
fba_dasd=
_dasdfmt() {
- local block="$(ls /sys/bus/ccw/devices/"$1"/block 2>/dev/null)" answer=
+ local block="$(ls /sys/bus/ccw/devices/"$1"/block 2>/dev/null)"
if ! [ -b "/dev/$block" ]; then
echo "/dev/$block is not a block device" >&2
else
- echo -n "WARNING: Erase ECKD DASD $1? [y/N]: "
- read answer
- case "$answer" in
- y*|Y*) dasdfmt -b 4096 -d cdl -yp "/dev/$block" ;;
- esac
+ if ask_yesno "WARNING: Erase ECKD DASD $1? (y/n)" "n"; then
+ dasdfmt -b 4096 -d cdl -yp "/dev/$block"
+ fi
fi
}
@@ -46,21 +44,20 @@ ask_eckd(){
local prompt="$1"
local help_func="$2"
shift 2
- local answer=
local default_dasd="all"
apk add --quiet s390-tools
- while ! all_in_list "$answer" $@ "$default_dasd" "abort" "done" "none"; do
+ resp=
+ while ! all_in_list "$resp" $@ "$default_dasd" "abort" "done" "none"; do
echo "Available ECKD DASD(s) are:"
show_dasd_info "$@"
- echon "$prompt [$default_dasd] "
- default_read answer $default_dasd
- case "$answer" in
+ ask "$prompt" "$default_dasd"
+ case "$resp" in
'abort') exit 0;;
'done'|'none') return 0;;
'?') $help_func;;
'all') for busid in $@; do _dasdfmt $busid; done;;
- *) for busid in $answer; do _dasdfmt $busid; done;;
+ *) for busid in $resp; do _dasdfmt $busid; done;;
esac
done
}