Created
November 8, 2019 13:05
-
-
Save odellt/819347013d5dca536abd80d68606a610 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Script to demonstrate capturing the exit status of a sub shell command while assigning the output to a local variable | |
test() { | |
local inline_declaration_and_definition=$(exit 3) | |
echo $? # output: 0 | |
local separate_declaration_and_definition | |
separate_declaration_and_definition=$(exit 3) | |
echo $? # output: 3 | |
} | |
test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment