gardenbas.blogg.se

Get out script
Get out script











Improved the answer of Tzunghsing, with more clear results and error re-direction, for silent usage: #!/usr/bin/env bash It could also make code more portable in a sense (if you have tons of scripts that may or may not be called in different ways), though it's much less clunky to just use return and exit where appropriate.

get out script get out script

This can be useful for quickly testing script changes in a single terminal while keeping a bunch of scrap code underneath the main exit/ return while you work. (terminal window stays open and accepts additional input) Read -p "Would you like to XYZ? (Y/N): " response The string is passed so that the function has access to the outer script's arguments. Either way it will keep the session open after "exiting". The following example can be run directly like foo.sh or sourced like.

get out script

Here's a related tip, if you ever want a script that should keep the session open, regardless of whether or not it's sourced. exit to keep the same session open, as others have noted.













Get out script