From 4eaafe08399ca1e95e2a3d6310fb655312385037 Mon Sep 17 00:00:00 2001 From: MarkGrimwood <83716751+MarkGrimwood@users.noreply.github.com> Date: Sun, 22 Aug 2021 19:15:03 +0100 Subject: [bash/en] Update bash.html.markdown (#4202) Additional info on arguments and return values for functions --- bash.html.markdown | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 () -- cgit v1.2.3