Created
September 23, 2018 08:39
-
-
Save antonagestam/6e0a401e33a5f237ebe48b75cad02942 to your computer and use it in GitHub Desktop.
get bash variables from a source
This file contains 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
#!/usr/bin/env bash | |
set -euo pipefail | |
get_from () { | |
local file=$1 | |
local variable=$2 | |
echo "$( | |
source "$file" > /dev/null | |
eval "echo \"\$$variable\"" | |
)" | |
} | |
get_from "$1" "$2" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment