I am calling a bash script that has a number of flags in the following manner:
/home/username/myscript -a -b 76
So to illustrate, the -a flag does something in myscript and the -b flag sets some parameter to 76 in myscript.
How do I make these flags conditional based on some previously defined variable? For example, I only want to use the -a flag if some variable var=ON, else I don't what to use that flag. I am looking for something like:
var=ON
/home/username/myscript
if [ "$var" == "ON" ]; then
-a
fi
-b 76
This scheme did not work when implemented, however. What can be used to accomplish the desired result?