From 371e6d1ab81a83545a74672be7c1675e936b8f6f Mon Sep 17 00:00:00 2001 From: daryl Date: Wed, 29 Jun 2022 11:56:15 +0930 Subject: [PATCH] Add 'bash/internal_function_w_output_and_return.bash' --- bash/internal_function_w_output_and_return.bash | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 bash/internal_function_w_output_and_return.bash diff --git a/bash/internal_function_w_output_and_return.bash b/bash/internal_function_w_output_and_return.bash new file mode 100644 index 0000000..48e5d22 --- /dev/null +++ b/bash/internal_function_w_output_and_return.bash @@ -0,0 +1,17 @@ +#!/bin/bash + +# How to have STDOUT going to the user from within an internal function that also has a return code for the bits +# outside the function to logic on. + +imma_function() +{ + echo "Imma inside the function! Param given is $1." + return 42 +} + +# call the function +imma_function foo + +status=$? + +echo $status # will echo 42 to output