-
Notifications
You must be signed in to change notification settings - Fork 11
fix(wp-helper): use shell parameter expansion to trim trailing space in wp_args log #4953
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -380,7 +380,9 @@ | |||||
| local site_type | ||||||
| site_type=$(echo "$site_config" | jq -r '.type') | ||||||
|
|
||||||
| print_info "Running on $site_name ($site_type): wp ${wp_args[*]}" >&2 | ||||||
| local args_str | ||||||
| args_str=$(printf '%q ' "${wp_args[@]}") | ||||||
| print_info "Running on $site_name ($site_type): wp ${args_str% }" >&2 | ||||||
|
|
||||||
| # Execute directly without eval | ||||||
| execute_wp_via_ssh "$site_config" "${wp_args[@]}" | ||||||
|
|
@@ -401,7 +403,9 @@ | |||||
| load_config | ||||||
|
|
||||||
| print_info "Running on all sites in category: $category" | ||||||
| print_info "Command: wp ${wp_args[*]}" | ||||||
| local args_str | ||||||
| args_str=$(printf '%q ' "${wp_args[@]}") | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using command substitution
Suggested change
References
|
||||||
| print_info "Command: wp ${args_str% }" | ||||||
| echo "" | ||||||
|
|
||||||
| local site_keys | ||||||
|
|
@@ -444,7 +448,9 @@ | |||||
| load_config | ||||||
|
|
||||||
| print_info "Running on ALL sites" | ||||||
| print_info "Command: wp ${wp_args[*]}" | ||||||
| local args_str | ||||||
| args_str=$(printf '%q ' "${wp_args[@]}") | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using command substitution
Suggested change
References
|
||||||
| print_info "Command: wp ${args_str% }" | ||||||
| echo "" | ||||||
|
|
||||||
| local site_keys | ||||||
|
|
@@ -537,7 +543,7 @@ | |||||
| echo " [skip] .aidevops-tenant (not found)" | ||||||
| fi | ||||||
| if [[ -f "$WP_ACTIVE_TENANT_FILE" ]]; then | ||||||
| echo " [found] active-tenant = $(tr -d '[:space:]' <"$WP_ACTIVE_TENANT_FILE")" | ||||||
|
Check warning on line 546 in .agents/scripts/wp-helper.sh
|
||||||
| else | ||||||
| echo " [skip] active-tenant (not set)" | ||||||
| fi | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using command substitution
$(...)creates a subshell. To make this more efficient and align with the goal of avoiding subshells, you can useprintf -v. This bash feature assigns the output directly to the variable without creating a new process.References
printf -valigns with this principle by assigning output directly to a variable without creating a new process, similar to using pure Bash parameter expansion.