I am pretty new to shell scripting and I have to add a flag (getopts) to my script where I can overwrite download url command if the script can’t reach the url for any reason. For instance, if I add my flag then it won’t terminate my script, I can choose to continue if url can’t be reached.
Currently, I have
if "$?" -ne "0" then
echo "can't reach the url, n\ aborting"
exit
Now I need to add a flag through getopts where I can choose to ignore "$?' - ne "0" command,
I don’t know how getopts works, I am pretty new to it. Can someone please help me on how to go about it?
If you only have one option, sometimes it’s simpler to just check
$1:If you’re going to accept other options, some possibly with arguments, the
getoptsshould be used: