plan9fox/rc/bin/inst/prepdisk
Alex Musolino 51669adf24 inst/prepdisk: fix invocations of test(1)
Test(1) was fixed some time ago [1] to properly parse all of its
command line arguments.  As such, we need to be more careful about
using test(1) with globbing patterns.

[1] changeset b562b269ce
2022-05-11 16:33:37 +00:00

53 lines
1.1 KiB
Bash
Executable file

#!/bin/rc
# desc: subdivide plan 9 disk partition
# prereq: partdisk
fn autotype {
switch($fstype){
case cwfs cwfs64 cwfs64x
echo -a 9fat -a nvram -a fscache -a fsworm -a other
case hjfs
echo -a 9fat -a nvram -a fs
}
}
switch($1) {
case checkready
disks=(/dev/sd*/plan9*)
if(! test -f $disks(1)){
prepdisk=notdone
export prepdisk
}
case go
echo 'The following Plan 9 disk partitions were found.'
echo
disks=(/dev/sd*/plan9*)
for (i in $disks){
echo $i
echo q | disk/prep -r $i >[2]/dev/null
echo
}
if(~ $#disks 1)
default=(-d $disks)
if not
default=()
prompt $default 'Plan 9 partition to subdivide' $disks
disk=$rd
echo 'This is disk/prep; use it to subdivide the Plan 9 partition.'
echo 'If it is not yet subdivided, a sensible layout will be suggested;'
echo 'you can probably just type ''w'' and then ''q''.'
echo
disk/prep `{autotype} $disk
disk/prep -p $disk >`{basename -d $disk}^/ctl >[2]/dev/null
case checkdone
disks=(/dev/sd*/9fat)
if(! test -f $disks(1))
prepdisk=ready
if(! ~ $prepdisk ready)
prepdisk=done
export prepdisk
}