fun with bash 2

Posted on

I’m reverse engineering a make file my team uses to something I can put together for my own use later … just in case. Here’s something I found which I didn’t understand which might be unique:


From this site ( ) i find this table:

Form Meaning
${variable?word} Complain if undefined
${variable-word} Use new value if undefined
${variable+word} Opposite of the above
${variable=word} Use new value if undefined, and redefine

So what we have is like a default value for a variable that we can also use to do stuff with. In my case I do something like this:

function check_parameters {
	if [ $test_val_three = 'benji' ]; then
	echo $test_val_three

..incase the user hasn’t entered anything as a parameter, or, they did and the keyword matches the default value. If the value is different from the default, then it prints out a different message like so:

else if it the keyword matches it prints this


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s