Created
October 10, 2022 22:47
-
-
Save olegon/c7a843e4b627775b0a65128394ab7d7c to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
IN=$(cat << HMARK | |
pacotes= a, b, c | |
testes= 1,2,3,4 | |
HMARK | |
) | |
readarray -t LINES <<< "$IN" | |
for LINE in "${LINES[@]}"; do | |
if [[ "$LINE" =~ ^pacotes[[:space:]]*=(.*)$ ]]; then | |
readarray -d "," -t PACKAGES <<< ${BASH_REMATCH[1]} | |
for PACKAGE in "${PACKAGES[@]}"; do | |
PACKAGE_WITHOUT_SPACES=$(echo $PACKAGE | xargs) | |
echo "package = \"$PACKAGE_WITHOUT_SPACES\"" | |
done; | |
elif [[ "$LINE" =~ ^testes[[:space:]]*=(.*)$ ]]; then | |
CAPTURED_VALUE=${BASH_REMATCH[1]} | |
readarray -d "," -t TESTS <<< ${BASH_REMATCH[1]} | |
for TEST in "${TESTS[@]}"; do | |
TEST_WITHOUT_SPACES=$(echo $TEST | xargs) | |
echo "test = \"$TEST_WITHOUT_SPACES\"" | |
done; | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment