Skip to content

Commit 22bbfae

Browse files
ZviBaratzclaude
andcommitted
fix(ego-lint): guard awk command substitutions against set -e abort
Bare `var=$(cmd)` under `set -euo pipefail` aborts the script if cmd returns non-zero. Add `|| true` to both minified-js awk invocations. Also add a boundary test fixture (2 long lines, below 3-line threshold). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 81a8020 commit 22bbfae

File tree

5 files changed

+31
-2
lines changed

5 files changed

+31
-2
lines changed

skills/ego-lint/scripts/ego-lint.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ for f in "$EXT_DIR"/*.js; do
424424
# Check for lines > 500 chars — need 3+ such lines to flag as minified.
425425
# A single long line (e.g., keyboard constant chain) in an otherwise
426426
# readable file is not minification.
427-
long_line_count=$(awk 'length > 500 { n++ } END { print n+0 }' "$f" 2>/dev/null)
427+
long_line_count=$(awk 'length > 500 { n++ } END { print n+0 }' "$f" 2>/dev/null || true)
428428
if [[ "$long_line_count" -ge 3 ]]; then
429429
minified_files+=" $rel_path ($long_line_count lines > 500 chars)"$'\n'
430430
fi
@@ -436,7 +436,7 @@ if [[ -d "$EXT_DIR/lib" ]]; then
436436
minified_files+=" $rel_path (webpack bundle)"$'\n'
437437
continue
438438
fi
439-
long_line_count=$(awk 'length > 500 { n++ } END { print n+0 }' "$f" 2>/dev/null)
439+
long_line_count=$(awk 'length > 500 { n++ } END { print n+0 }' "$f" 2>/dev/null || true)
440440
if [[ "$long_line_count" -ge 3 ]]; then
441441
minified_files+=" $rel_path ($long_line_count lines > 500 chars)"$'\n'
442442
fi
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SPDX-License-Identifier: GPL-2.0-or-later

tests/fixtures/minified-boundary@test/extension.js

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"uuid": "minified-boundary@test",
3+
"name": "Minified Boundary Test",
4+
"description": "Tests that 2 long lines do not trigger minified-js detection",
5+
"shell-version": ["48"],
6+
"url": "https://example.com"
7+
}

tests/run-tests.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,12 @@ assert_exit_code "exits with 1 (has failures)" 1
191191
assert_output_contains "fails on minified JS" "\[FAIL\].*minified-js"
192192
echo ""
193193

194+
# --- minified-boundary (2 long lines — below threshold) ---
195+
echo "=== minified-boundary ==="
196+
run_lint "minified-boundary@test"
197+
assert_output_not_contains "no minified-js with only 2 long lines" "\[FAIL\].*minified-js"
198+
echo ""
199+
194200
# --- lifecycle-imbalance ---
195201
echo "=== lifecycle-imbalance ==="
196202
run_lint "lifecycle-imbalance@test"

0 commit comments

Comments
 (0)