0

I am having a hard time figuring out how to handle a set of paramters in bash:

The script contains mandatory options to set when running it, and those options then have their own parameters that I would like the script to handle in a case specific manner.

script.sh -extension -render -r[1-99] -directory /path/

or

script.sh -extension -export -e[1-99] -directory /path/

if I am to pass the render option, i would like the script to iterate and validate the options that are only specific to the rendering parameter (r1, r2, r3,...) and vice versa for the export feature.

Meaning, running -render -e[n] would throw an error and/or prompt the user to choose the appropriate sub-option or default to a preset that is already there.

chepner
  • 497,756
  • 71
  • 530
  • 681
  • So you want to run `script.sh -extension -render -r1 -directory /path/` and `script.sh -extension -render -r2 -directory /path/` and `script.sh -extension -render -r3 -directory /path/` ........ `script.sh -extension -render -r99 -directory /path/`? – KamilCuk Jan 28 '20 at 14:16
  • @KamilCuk, sorry if i was unclear: -r[1-99] was meant to say 'any sub-option to -render' - that being said, i would only run script.sh -render -r1 -directory /path/, and if I were to do script.sh -export -r1 -directory /path/ it should throw some error or message to correct the argument being used. – nathanel.titane Jan 28 '20 at 14:18

0 Answers0