Commit acd28ded38e8

Vincent Demeester <vincent@sbr.pm>
2026-01-30 22:47:02
fix(gh-news-review): use temp script to avoid nested quoting
The ssh→shpool→bash -lc chain had complex quoting issues causing "zsh: unmatched quote" errors. Rewrote to write a temp script file on the remote and execute that instead, avoiding all nested quoting. Uses heredoc with base64-encoded prompt to handle special characters. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 7b18d38
Changed files (1)
pkgs
my
scripts
pkgs/my/scripts/bin/gh-news-review
@@ -69,19 +69,25 @@ if [[ "$YOLO" == "true" ]]; then
     CR_CMD="cr --dangerously-skip-permissions"
 fi
 
-# Command to run in shpool session
-# Use absolute path to bash since shpool's default PATH doesn't include NixOS paths
-# bash -lc sources login profile to get Nix paths where cr is located
-# cd to src/nixpkgs so Claude has access to the codebase for reviews
-SHPOOL_CMD="shpool attach -f -c '/run/current-system/sw/bin/bash -lc \"cd ~/src/nixpkgs && $CR_CMD \\\"$PROMPT\\\"\"' $SESSION_NAME"
+# Encode prompt in base64 to avoid all quoting issues
+PROMPT_B64=$(printf '%s' "$PROMPT" | base64 -w0)
 
 if [[ "$DETACH" == "true" ]]; then
-    # Start in background and return immediately
-    # shellcheck disable=SC2029  # Intentional client-side expansion
-    ssh aomi.sbr.pm "nohup $SHPOOL_CMD > /dev/null 2>&1 &"
+    # Write a temp script on remote and execute it in shpool
+    # Using heredoc avoids all nested quoting issues
+    # shellcheck disable=SC2029,SC2087  # Intentional client-side expansion
+    ssh aomi.sbr.pm "cat > /tmp/review-cmd-$SESSION_NAME.sh && chmod +x /tmp/review-cmd-$SESSION_NAME.sh && nohup shpool attach -f -c '/run/current-system/sw/bin/bash -l /tmp/review-cmd-$SESSION_NAME.sh' $SESSION_NAME > /dev/null 2>&1 &" <<EOF
+cd ~/src/nixpkgs
+$CR_CMD "\$(echo '$PROMPT_B64' | base64 -d)"
+EOF
     echo "Started review session: $SESSION_NAME"
     echo "Attach with: ssh -t aomi.sbr.pm 'shpool attach $SESSION_NAME'"
 else
-    # Interactive mode - attach to session
-    exec ssh -t aomi.sbr.pm "$SHPOOL_CMD"
+    # Interactive: write temp script and run
+    # shellcheck disable=SC2029,SC2087  # Intentional client-side expansion
+    ssh aomi.sbr.pm "cat > /tmp/review-cmd-$SESSION_NAME.sh && chmod +x /tmp/review-cmd-$SESSION_NAME.sh" <<EOF
+cd ~/src/nixpkgs
+$CR_CMD "\$(echo '$PROMPT_B64' | base64 -d)"
+EOF
+    exec ssh -t aomi.sbr.pm "shpool attach -f -c '/run/current-system/sw/bin/bash -l /tmp/review-cmd-$SESSION_NAME.sh' $SESSION_NAME"
 fi