summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMarkGrimwood <83716751+MarkGrimwood@users.noreply.github.com>2021-08-22 19:15:03 +0100
committerGitHub <noreply@github.com>2021-08-22 20:15:03 +0200
commit4eaafe08399ca1e95e2a3d6310fb655312385037 (patch)
tree5ee24f26cb215be0ff27849a213c96c7e7ed531d
parent68f016d886c755acff58782514a79f5203201fa1 (diff)
[bash/en] Update bash.html.markdown (#4202)
Additional info on arguments and return values for functions
-rw-r--r--bash.html.markdown7
1 files changed, 6 insertions, 1 deletions
diff --git a/bash.html.markdown b/bash.html.markdown
index 11ce4e74..4ed638e6 100644
--- a/bash.html.markdown
+++ b/bash.html.markdown
@@ -17,6 +17,7 @@ contributors:
- ["John Detter", "https://github.com/jdetter"]
- ["Harry Mumford-Turner", "https://github.com/harrymt"]
- ["Martin Nicholson", "https://github.com/mn113"]
+ - ["Mark Grimwood", "https://github.com/MarkGrimwood"]
filename: LearnBash.sh
translators:
- ["Dimitri Kokkonis", "https://github.com/kokkonisd"]
@@ -402,13 +403,17 @@ function foo ()
echo "Arguments work just like script arguments: $@"
echo "And: $1 $2..."
echo "This is a function"
- return 0
+ returnValue=0 # Variable values can be returned
+ return $returnValue
}
# Call the function `foo` with two arguments, arg1 and arg2:
foo arg1 arg2
# => Arguments work just like script arguments: arg1 arg2
# => And: arg1 arg2...
# => This is a function
+# Return values can be obtained with $?
+resultValue=$?
+# More than 9 arguments are also possible by using braces, e.g. ${10}, ${11}, ...
# or simply
bar ()