Sample Header Ad - 728x90

Bash getopts error handling

-2 votes
1 answer
956 views
This is an error I encountered when playing with Getopts. The following is the code snippet I have been playing simply listen to 3 options when executing a script. while getopts "vcn" opt; do case $opt in v) echo "Print V" ;; c) echo "Print C" ;; n) echo "Print N" ;; *) echo "Invalid Option" && exit 1 ;; esac done I'm not sure Why I'm getting the below error when executing this script even though I have handled errors with *) option to do so. The error handle is working as shown in the picture below but after getting an unprogrammed error. The Error msg on the terminal
Asked by Dettlaff404 (3 rep)
Jan 7, 2024, 11:47 AM
Last activity: Jan 7, 2024, 07:21 PM