-
Notifications
You must be signed in to change notification settings - Fork 8
hotfix: use NUL-delimited IPC for dispatch command builder #654
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 | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2595,29 +2595,30 @@ build_dispatch_cmd() { | |||||||||||||||
| $memory_context" | ||||||||||||||||
| fi | ||||||||||||||||
|
|
||||||||||||||||
| # Use NUL-delimited output so multi-line prompts stay as single arguments | ||||||||||||||||
| if [[ "$ai_cli" == "opencode" ]]; then | ||||||||||||||||
| echo "opencode" | ||||||||||||||||
| echo "run" | ||||||||||||||||
| echo "--format" | ||||||||||||||||
| echo "json" | ||||||||||||||||
| printf '%s\0' "opencode" | ||||||||||||||||
| printf '%s\0' "run" | ||||||||||||||||
| printf '%s\0' "--format" | ||||||||||||||||
| printf '%s\0' "json" | ||||||||||||||||
| if [[ -n "$model" ]]; then | ||||||||||||||||
| echo "-m" | ||||||||||||||||
| echo "$model" | ||||||||||||||||
| printf '%s\0' "-m" | ||||||||||||||||
| printf '%s\0' "$model" | ||||||||||||||||
| fi | ||||||||||||||||
| echo "--title" | ||||||||||||||||
| echo "$task_id" | ||||||||||||||||
| echo "$prompt" | ||||||||||||||||
| printf '%s\0' "--title" | ||||||||||||||||
| printf '%s\0' "$task_id" | ||||||||||||||||
| printf '%s\0' "$prompt" | ||||||||||||||||
| else | ||||||||||||||||
| # claude CLI | ||||||||||||||||
| echo "claude" | ||||||||||||||||
| echo "-p" | ||||||||||||||||
| echo "$prompt" | ||||||||||||||||
| printf '%s\0' "claude" | ||||||||||||||||
| printf '%s\0' "-p" | ||||||||||||||||
| printf '%s\0' "$prompt" | ||||||||||||||||
| if [[ -n "$model" ]]; then | ||||||||||||||||
| echo "--model" | ||||||||||||||||
| echo "$model" | ||||||||||||||||
| printf '%s\0' "--model" | ||||||||||||||||
| printf '%s\0' "$model" | ||||||||||||||||
| fi | ||||||||||||||||
| echo "--output-format" | ||||||||||||||||
| echo "json" | ||||||||||||||||
| printf '%s\0' "--output-format" | ||||||||||||||||
| printf '%s\0' "json" | ||||||||||||||||
| fi | ||||||||||||||||
|
|
||||||||||||||||
| return 0 | ||||||||||||||||
|
|
@@ -3101,8 +3102,9 @@ cmd_dispatch() { | |||||||||||||||
| log_info "Log: $log_file" | ||||||||||||||||
|
|
||||||||||||||||
| # Build and execute dispatch command | ||||||||||||||||
| # Use NUL-delimited read to preserve multi-line prompts as single arguments | ||||||||||||||||
| local -a cmd_parts=() | ||||||||||||||||
| while IFS= read -r part; do | ||||||||||||||||
| while IFS= read -r -d '' part; do | ||||||||||||||||
| cmd_parts+=("$part") | ||||||||||||||||
| done < <(build_dispatch_cmd "$task_id" "$worktree_path" "$log_file" "$ai_cli" "$memory_context" "$tmodel" "$tdesc") | ||||||||||||||||
|
Comment on lines
3106
to
3109
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. The
Suggested change
References
|
||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
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.
This block contains a number of repetitive
printfcalls. To improve readability and maintainability, you can build an array of command parts first and then print all elements at once with a singleprintfcall. This approach reduces code duplication.References
eval, applying the same principle of using arrays here improves code clarity and maintainability. (link)