...
Warning |
---|
Make sure you have spaces inside the [] otherwise bash will sit spit the dummy! |
Code Block |
---|
language | bash |
---|
theme | RDark |
---|
title | Check for Success |
---|
collapse | true |
---|
|
if [ $? -eq 0 ]; then
echo "Success"
else
echo "Failure" |
...
Code Block |
---|
language | bash |
---|
theme | RDark |
---|
title | Check for Failure |
---|
collapse | true |
---|
|
if [ $? -ne 0 ]; then
echo "Failure"
else
echo "Success" |
Conditionally Exit
Code Block |
---|
language | bash |
---|
theme | RDark |
---|
title | Exit with Error in 1-Line |
---|
collapse | true |
---|
|
# Use braces
CARLA_TARBALL=`ls ${CARLA_ROOT}/Distd/*.tar.gz 2> /dev/null` || { echo "Carla tarball not found, exiting." ; exit 1; } |
Conditionally Set Variables
Code Block |
---|
language | bash |
---|
theme | RDark |
---|
title | Set if not already defined |
---|
collapse | true |
---|
|
: ${var=value} |
This one is obscure....<TODO> explain!
Code Block |
---|
language | bash |
---|
theme | RDark |
---|
title | Set if not defined OR set to the empty string |
---|
collapse | true |
---|
|
: ${var:=value} |
...