IF statement output in bash? -
when run script first question asks "would use curl? [y/n]:" reply y or y. however, when instant output "unknown!". i'm expecting see next question code "great, want ignore certificates [y/n]: "
can edit code make work expected? , tell me why?
#!/bin/bash echo "build command" read -r -e -p "would use curl? [y/n]: " curlstring="curl" if [[ "${input,,}" == "y" ]]; read -r -e -p "great, want ignore certificates [y/n]: " input if [[ "$input" == "y" ]]; curlstring=$curlstring" -k" else curlstring=$curlstring" " fi echo "$curlstring" elif [[ "${input,,}" == "n" ]]; echo "bye" else echo "unknown!" exit 0 fi
the error not capturing user input first read
command, change it,
read -r -e -p "would use curl? [y/n]: " input
also bash
quite sensitive constructs used, line number 15
fi echo "$curlstring"
will throw syntax error saying below when give y
or y
1 of options,
would use curl? [y/n]: y script.sh: line 15: syntax error near unexpected token `echo' script.sh: line 15: ` fi echo "$curlstring" '
change separate lines.
Comments
Post a Comment