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