You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Is there a way pass undefined params and the shell script will not FATAL and exit #56
Sometimes, we may pass some undefined params to shell script, is there a way(such as a flag) to ignore the undefined params, and the script will run success?
Now the script will have a FATAL error and exit when we pass undefined params
This is covered in the Quick Start, but maybe that could be improved or documented elsewhere. Where did you look (and not find) an answer?
This is a copy-and-paste from the current 1.3 docs (linked above). I've bolded the line relevant for you. Let me know if you have improvement suggestions.
# parse the command-line
FLAGS "$@" || exit $?
eval set -- "${FLAGS_ARGV}"
Here is where all the magic happens. The call to FLAGS with the passing of $@ sends all command-line arguments into the shFlags library for processing. If everything is successful, a return value of 0 (${FLAGS_TRUE}) is returned an things continue. If a false value of 1 (${FLAGS_FALSE}) or an error value of 2 (${FLAGS_ERROR}) is returned, the processing is halted, returning that value (the exit $?). If there are any command-line arguments left over that shFlags didn't know how to process, they are now present in the now updated $@ variable, which can be used as with any other script.
Sometimes, we may pass some undefined params to shell script, is there a way(such as a flag) to ignore the undefined params, and the script will run success?
Now the script will have a FATAL error and exit when we pass undefined params