Created
February 15, 2023 12:48
-
-
Save taikedz/29c31fe347b49c8d928e39d2bdea16e5 to your computer and use it in GitHub Desktop.
Shell: Array split in quoted string
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
#!/usr/bin/env bash | |
QUOTED_ARRAY="-Djava=\"one 'and' two\" -Djavax=\"three four\"" | |
while IFS= read -r -d '' item; do echo "$item"; done < <(xargs printf '%s\0' <<< "$QUOTED_ARRAY") | |
# Output: | |
# -Djava=one 'and' two | |
# -Djavax=three four | |
# obtained from /usr/local/bin/jenkins.sh in the Jenkins sdk17 docker image |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment