Accept return as a valid answer to 'Edit the file again?'

Also, check for affirmative answer so a random string isn't taken as a
"yes" response.
This commit is contained in:
sentriz 2017-08-12 00:09:13 +01:00 committed by Kurtis Rader
parent 058e23720f
commit 72173a93a7

View File

@ -105,10 +105,13 @@ function funced --description 'Edit function definition'
echo # add a line between the parse error and the prompt
set -l repeat
set -l prompt (_ 'Edit the file again\? [Y/n]')
while test -z "$repeat"
read -p "echo $prompt\ " repeat
end
if not contains $repeat n N no NO No nO
read -p "echo $prompt\ " response
if test -z "$response"
or contains $response {Y,y}{E,e,}{S,s,}
continue
else if not contains $response {N,n}{O,o,}
echo "I don't understand '$response', assuming 'Yes'"
sleep 2
continue
end
echo (_ "Cancelled function editing")