I'm writing a bash script that leverages getopt to process a number of options provided after the script name.
I'm accessing my shell through puTTy.
I invoke the script with . scriptname.sh -o --options (is there a better way to execute a bash script?)
I'd like to be able to abort / halt the script, but whenever I use exit
it not only exits the script, it also closes the terminal/puTTy window.
...which kinda defeats the purpose because what I'm trying to do is set up some kind of --help text output that displays the text but doesn't execute the rest of the script.
What's the deal with exit
and what should I use to halt/abort the script without closing any parent console window?
.
is the same as using thesource
command (help source
for usage) and is not a good idea if you really wanted to execute the script. Insteadchmod a+x scriptname.sh
and then use./scriptname.sh
to invoke.