I have a program which is basically written in sh (has to be) and it is trying to read inputs from the command line and if no input is given then it takes the default value.
Here is the code
if [ -f /.default ]
#Set Default Values from the file
while getopts D:w:r:h:p:i:t: name
case $name in
p) if [ $TYPE = option1 ]
elif [ $TYPE = option2 ]
i) if [ $TYPE = option1 ] ; then
elif [ $TYPE = option2 ] ; then
Basically if the file is called test.sh I want the user to run it with mininum commands
./test -t (option1|option2)
Once he specifies that, and if all the other are not specified (i.e. D w r h etc) then it will take the default.. If even -D -w -r etc are mentioned then it overrides the default value
This script is not working. It is sourcing correctly from the file and assigning the default value and echo out is correct. But I think because I am not mentioning -D -w -r etc , the getopts does not work
Can anyone suggest how to get this working??