Add 'bash/internal_function_w_output_and_return.bash'
This commit is contained in:
17
bash/internal_function_w_output_and_return.bash
Normal file
17
bash/internal_function_w_output_and_return.bash
Normal 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
|
||||
Reference in New Issue
Block a user