I am wondering about some use case with bash script. Imagine that user type:
./my_script.sh INSTALL=FALSE
and then package is installed without any dependencies or type INSTALL=TRUE
and then package is installed with all dependencies.
Now the script should know that INSTALL=FALSE
is default way so it means that is okay to type just
./my_script.sh
but user needs to specify
./my_script.sh INSTALL=TRUE
if he wants to install package with all dependencies.
Is it possible? How to do it?
CodePudding user response:
If you want your script to remember the config, you should create a config file with correct setting.
- If script ran without any argument, read config file.
- If config file doesn't exist, create it with
INSTALL=FALSE
- If script was given an argument, overwrite new setting to config file.
If script ran without any argument, and config file doesn't exist, create a config file with INSTALL=FALSE