bash3boilerplate
bash3boilerplate copied to clipboard
Long-form invalid arguments aren't caught
Example:
read -r -d '' __usage <<-'EOF' || true # exits non-zero when EOF encountered
-s --subject [arg] Specific subject files to process.
-v --verbose Enable verbose mode for all scripts.
-d --debug Enables debug mode.
-h --help This help page.
-n --dry-run Don't submit any jobs.
-r --reg-command [arg] Provide an alternative registration command. Default="mb_register.sh"
-f --factor [arg] Scaling factor for time and memory estimates. Default="1.15"
EOF
read -r -d '' __helptext <<-'EOF' || true # exits non-zero when EOF encountered
MAGeTBrain implementation using ANTs
Supports MINC and NIFTI input files (ANTs must be built with MINC support)
Invocation: mb.sh [options] -- [stage 1] [stage 2] ... [stage N]
Standard stages: template, subject, resample, vote, run (template, subject, resample, vote)
Multiatlas stages: multiatlas-resample, multiatlas-vote, multiatlas (template, multiatlas-resample, multiatlas-vote)
Other stages: init, status, cleanup
Multiple commands will run multiple stages. Order is not checked.
EOF
User tried to do:
$ mb.sh --template
#Instead of
$ mb.sh -- template
There was no error thrown for the invalid command-line option "--template"
Throwing on that would have to be opt-in I feel, as I could imagine use cases where the argument is unknown / passed on to something else
Sure, I'm okay with that, just not what I expected from default parsers in other languages.
Yes, I think Open coarrays build script passed arguments to other scripts, only some of which are actually consumed. Been meaning to add an opt-in check for invalid flags.