PortValhalla/lib/modules/partition/confirm.fish

29 lines
626 B
Fish
Raw Normal View History

2024-09-22 16:51:10 +00:00
#!/bin/env fish
function confirm -a message default
set -l options (echo "[y/n]" | string replace $default (string upper $default))
while true
read -l value -P "$message $options "
set value (string lower "$value")
if [ -z "$value" ]
set value $default
end
if contains "$value" "0" "false" "n" "no"
false
return
end
if contains "$value" "1" "true" "y" "yes"
true
return
end
echo "The specified value `$value` is invalid!"
echo "Please try again"
end
end
confirm $argv