Make foreach-bundle a proper shell script#36
Conversation
|
Should I include |
|
@szepeviktor Out of curiosity, what functional benefit does this provide? |
|
@danielbachhuber This is the way one writes Bash scripts. This is the natural way. |
| BUNDLE_DEPENDENCIES=$(curl --silent https://raw.githubusercontent.com/wp-cli/wp-cli-bundle/master/composer.json -q | jq '.["require"] | keys[]' ) | ||
| BUNDLE_DEPENDENCIES=$(echo "wp-cli/wp-cli-bundle $BUNDLE_DEPENDENCIES") | ||
| get_bundle_dependencies() |
There was a problem hiding this comment.
- functionality goes into functions
- no variable reuse
| #!/usr/bin/env bash | ||
| # | ||
| # Execute a command in each subfolder. | ||
| # |
There was a problem hiding this comment.
Inform the reader.
| fi | ||
| esac | ||
| done | ||
| while read -r dependency; do |
There was a problem hiding this comment.
pipe a function's output into a while loop, for loops are a bit more dangerous
| if [ ! -d "${repo_path}" ]; then | ||
| continue | ||
| fi |
There was a problem hiding this comment.
bail out early: make the code flow nicely
|
|
||
| echo "--- ${repo_path}: ---" | ||
| cd "${repo_path}" | ||
| bash -c "$@" |
There was a problem hiding this comment.
never use "$@" alone
|
Great, thanks for clarifying @szepeviktor 😊 Let's get a second opinion from @schlessera |
|
Yes, the above sounds good to me. That script was just a quick hack I assembled and was never meant to be added as-is. But as we already have it included, we better make sure it is properly built. |
|
Thank you. |
☣️ This is highly theoretic: mostly written in GitHub editor.