Skip to content

Commit abc2115

Browse files
committed
fix: escaping chars in demo-trace (#55)
1 parent 449ca07 commit abc2115

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

scripts/demo_trace.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,10 @@ fi
9696
resolve_trace_dir
9797
log "Sending task: $TASK"
9898
before_size=$(filesize "$LOG")
99-
ros2 topic pub --once /user_tasks std_msgs/msg/String "{data: '${TASK//\'/\'\\\'\'}'}" >/dev/null
99+
# ros2 parses the message arg with yaml.safe_load; JSON is valid YAML, so let
100+
# json.dumps handle escaping (quotes, backslashes, newlines, unicode) for us.
101+
ros2 topic pub --once /user_tasks std_msgs/msg/String \
102+
"$(python3 -c 'import json, sys; print(json.dumps({"data": sys.argv[1]}))' "$TASK")" >/dev/null
100103

101104
# ── 5. Wait for completion ──────────────────────────────────────────────────
102105
# Prefer the precise marker the callback writes on the root chain end; fall back

0 commit comments

Comments
 (0)