summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--distrib/miniroot/install.sh8
-rw-r--r--distrib/miniroot/install.sub55
2 files changed, 31 insertions, 32 deletions
diff --git a/distrib/miniroot/install.sh b/distrib/miniroot/install.sh
index 8cb75b36b71..bea8c128c12 100644
--- a/distrib/miniroot/install.sh
+++ b/distrib/miniroot/install.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-# $OpenBSD: install.sh,v 1.131 2003/06/27 22:40:40 krw Exp $
+# $OpenBSD: install.sh,v 1.132 2003/06/30 17:49:14 krw Exp $
# $NetBSD: install.sh,v 1.5.2.8 1996/08/27 18:15:05 gwr Exp $
#
# Copyright (c) 1997-2002 Todd Miller, Theo de Raadt, Ken Westerback
@@ -98,8 +98,10 @@ if [ ! -f /etc/fstab ]; then
cat /dev/null >$FILESYSTEMS
cat /dev/null >$SWAPLIST
else
- ask_which "disk" "do you wish to initialize?" "$_DKDEVS"
- [ "$resp" = "done" ] && break
+ # Force the user to think and type in a disk name by
+ # making 'done' the default choice.
+ ask_which "disk" "do you wish to initialize?" "$_DKDEVS" done
+ [[ $resp == done ]] && break
fi
DISK=$resp
diff --git a/distrib/miniroot/install.sub b/distrib/miniroot/install.sub
index eee708c0cf5..1dbdfa557ff 100644
--- a/distrib/miniroot/install.sub
+++ b/distrib/miniroot/install.sub
@@ -1,4 +1,4 @@
-# $OpenBSD: install.sub,v 1.308 2003/06/30 14:25:53 krw Exp $
+# $OpenBSD: install.sub,v 1.309 2003/06/30 17:49:14 krw Exp $
# $NetBSD: install.sub,v 1.5.2.8 1996/09/02 23:25:02 pk Exp $
#
# Copyright (c) 1997-2003 Todd Miller, Theo de Raadt, Ken Westerback
@@ -230,38 +230,36 @@ ask_until () {
# $1 = device name (disk, cd, etc.)
# $2 = question to ask
# $3 = list of devices from /var/run/dmesg.boot scan
-# $4 = default device
+# $4 = default device. If it is not specified, use the first device in $3.
#
# $resp holds device selected at exit, or 'done'
ask_which () {
local _name=$1 _query=$2 _devs=$3 _defdev=$4
-
- # If not default device is supplied, assume 'done'.
- : ${_defdev:=done}
-
- # A trailing space may be present if _devs list
- # was manipulated by rmel().
- _devs=${_devs% }
-
- resp=
- if [[ -z $_devs ]]; then
+
+ set -- $_devs
+ if [[ $# < 1 ]]; then
echo "Done - no available ${_name}s found."
resp=done
+ return
fi
+ : ${_defdev:=$1}
- while [ -z "$resp" ]; do
+ # Eliminate extraneous (especially trailing) whitespace in _devs.
+ _devs="$*"
+
+ while : ; do
# Put both lines in ask prompt, rather than use a
- # separate 'echo', to ensure entire question is
- # re-ask'ed after a '!' '!foo' shell escape.
+ # separate 'echo' to ensure the entire question is
+ # re-ask'ed after a '!' or '!foo' shell escape.
ask "Available ${_name}s are: ${_devs}.\nWhich one $_query (or 'done')" "$_defdev"
+ [[ $resp == done ]] && break
# Quote $resp to prevent user from confusing isin() by
# entering something like 'a a'.
- if isin "$resp" $_devs ; then
- makedev $resp || resp=
- elif [ "$resp" != "done" ]; then
+ if isin "$resp" $_devs; then
+ makedev $resp && break
+ else
echo "'$resp' is not a valid choice."
- resp=
fi
done
}
@@ -433,9 +431,6 @@ makedev() {
get_rootdisk() {
local _defdsk
- _defdsk=$(echo $DKDEVS | cutword 1)
- [[ $_defdsk == $DKDEVS ]] || _defdsk=
-
if [[ $MODE == install && ! -f /etc/fstab ]]; then
cat << __EOT
@@ -450,6 +445,9 @@ fi
ROOTDEV=
SWAPDEV=
+ set -- $DKDEVS
+ [[ $# > 1 ]] && _defdsk=done
+
ask_which "disk" "is the root disk?" "$DKDEVS" "$_defdsk"
[[ $resp == done ]] && exit
@@ -531,9 +529,8 @@ configure_all_interfaces() {
while : ; do
_IFDEVS=`rmel "$_ifs" $_IFDEVS`
- ask_which "interface" "do you wish to initialize?" "$_IFDEVS" "`echo $_IFDEVS | cutword 1`"
-
- [ "$resp" = "done" ] && break
+ ask_which "interface" "do you wish to initialize?" "$_IFDEVS"
+ [[ $resp == done ]] && break
_ifs=$resp
configure_ifs $_ifs || _ifs=
@@ -1054,8 +1051,8 @@ install_mounted_fs() {
install_cdrom() {
local _drive _part _fstype _directory _n
- ask_which "CD-ROM" "contains the ${MODE} media?" "$CDDEVS" "`echo $CDDEVS | cutword 1`"
- [ "$resp" = "done" ] && return
+ ask_which "CD-ROM" "contains the ${MODE} media?" "$CDDEVS"
+ [[ $resp == done ]] && return
_drive=$resp
@@ -1139,8 +1136,8 @@ mount_a_disk() {
local _drive _def_partition _partition_range _partition
local _fstype _fsopts
- ask_which "disk" "contains the ${MODE} sets?" "$DKDEVS" "`echo $DKDEVS | cutword 1`"
- [ "$resp" = "done" ] && return 1
+ ask_which "disk" "contains the ${MODE} sets?" "$DKDEVS"
+ [[ $resp == done ]] && return 1
_drive=$resp