Skip to content

Commit 1cbec99

Browse files
lpcoxCopilot
andauthored
fix: eliminate piped while loops in token optimizer workflows (#24354)
Replace find | head -1 | while read piped pattern with command substitution in copilot-token-optimizer and claude-token-optimizer to avoid potential SIGPIPE under set -euo pipefail. Also fix claude-token-usage-analyzer jq line to match copilot variant: use []?.databaseId (optional object access) with 2>/dev/null || true. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 2ce9b7b commit 1cbec99

6 files changed

Lines changed: 59 additions & 57 deletions

.github/workflows/claude-token-optimizer.lock.yml

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/claude-token-optimizer.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,11 @@ steps:
163163
echo "Found workflow source: $WORKFLOW_MD"
164164
cp "$WORKFLOW_MD" /tmp/token-optimizer-claude/workflow-source.md
165165
else
166-
find .github/workflows -name "*.md" -exec grep -l "^name: $WORKFLOW_NAME" {} \; 2>/dev/null | head -1 | while read -r f; do
167-
echo "Found: $f"
168-
cp "$f" /tmp/token-optimizer-claude/workflow-source.md
169-
done
166+
FOUND_MD=$(find .github/workflows -name "*.md" -exec grep -l "^name: $WORKFLOW_NAME" {} \; 2>/dev/null | head -1 || true)
167+
if [ -n "$FOUND_MD" ]; then
168+
echo "Found: $FOUND_MD"
169+
cp "$FOUND_MD" /tmp/token-optimizer-claude/workflow-source.md
170+
fi
170171
fi
171172
172173
# Extract declared tools from workflow source

0 commit comments

Comments
 (0)