0

A bash script takes several input arguments. First argument is required, and others are optional flags:

./go.sh NAME [configuration arguments]

for example

./go.sh test -flag1=true -flag2=true -test_flag=true

Configuration arguments are a set of optional flags which I access in the script as:

CONF_ARGS="${@:2}"

I need to detect if one of those flags, called test_flag, is set to true. How would I do that?

Danijel
  • 7,354
  • 18
  • 64
  • 114
  • Generally, it's best to parse the options and arguments all at once, at the beginning of the script, and set variables based on them. Then in the main part of the script, just check the variables. See ["How do I parse command line arguments in Bash?"](https://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash) (but note that not all methods support long options and/or options after positional arguments). – Gordon Davisson Nov 15 '21 at 18:42

0 Answers0