summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNami-Doc <vendethiel@hotmail.fr>2013-12-18 00:45:45 -0800
committerNami-Doc <vendethiel@hotmail.fr>2013-12-18 00:45:45 -0800
commit7ca48c47098c35fb449d63812be2a620adf5ec60 (patch)
treec844600c8ee726d2b3fda2d28131a017eae7759e
parent6ca2a8dd4754c4b4fd3c52ee525e4b9f2e15d212 (diff)
parentc9a282d08fb1f8670fa328e0e7cdb8801382b88a (diff)
Merge pull request #458 from darh/master
Add example for default value
-rw-r--r--bash.html.markdown5
1 files changed, 5 insertions, 0 deletions
diff --git a/bash.html.markdown b/bash.html.markdown
index 1f1c32c0..815290dd 100644
--- a/bash.html.markdown
+++ b/bash.html.markdown
@@ -5,6 +5,7 @@ contributors:
- ["Max Yankov", "https://github.com/golergka"]
- ["Darren Lin", "https://github.com/CogBear"]
- ["Alexandre Medeiros", "http://alemedeiros.sdf.org"]
+ - ["Denis Arh", "https://github.com/darh"]
filename: LearnBash.sh
---
@@ -45,6 +46,10 @@ echo '$VARIABLE'
echo ${VARIABLE/Some/A}
# This will substitute the first occurance of "Some" with "A"
+# Default value for variable
+echo ${FOO:-"DefaultValueIfFOOIsMissingOrEmpty"}
+# This works for null (FOO=), empty string (FOO=""), zero (FOO=0) returns 0
+
# Bultin variables:
# There are some useful builtin variables, like
echo "Last program return value: $?"