Add 'bash/internal_function_w_output_and_return.bash'

This commit is contained in:
daryl
2022-06-29 11:56:15 +09:30
parent 710513d471
commit 371e6d1ab8

View File

@@ -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