#!/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 " or exit 1 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