From b1d4334571446ca5f23c050dcecfe0b5d7228ba8 Mon Sep 17 00:00:00 2001 From: usa- Date: Sun, 20 Sep 2026 11:29:57 +0300 Subject: [PATCH 1/2] Update strip-shell-comments.awk --- general/scripts/strip-shell-comments.awk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/general/scripts/strip-shell-comments.awk b/general/scripts/strip-shell-comments.awk index 0f6c757548..72ee986800 100644 --- a/general/scripts/strip-shell-comments.awk +++ b/general/scripts/strip-shell-comments.awk @@ -104,7 +104,7 @@ BEGIN { nd = 0; sq = 0; dq = 0; cont = 0; prev_cont = 0 } next } - if (/^[ \t]*$/) next + if (/^[ \t]*$/) { print; next } code = code_of($0) if (code ~ /^[ \t]*$/) next # the line was only a comment From 7a02ff0250e74db765213a7ee09da708a3c6174c Mon Sep 17 00:00:00 2001 From: usa- Date: Sun, 20 Sep 2026 18:11:55 +0300 Subject: [PATCH 2/2] Address review comments --- .github/scripts/test_strip_shell_comments.sh | 8 ++++++++ general/scripts/strip-shell-comments.awk | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/scripts/test_strip_shell_comments.sh b/.github/scripts/test_strip_shell_comments.sh index ca6b1bd020..8341d3b1d2 100755 --- a/.github/scripts/test_strip_shell_comments.sh +++ b/.github/scripts/test_strip_shell_comments.sh @@ -72,6 +72,14 @@ else ok "plain and indented comment lines are dropped" fi +# #2386: blank lines stay, so the shipped script keeps its paragraph breaks. +printf '#!/bin/sh\necho one\n\necho two\n' > "$WORK/blank.sh" +if [ "$(strip "$WORK/blank.sh" | wc -l)" = 4 ]; then + ok "blank lines survive" +else + bad "a blank line was dropped" +fi + live=$(grep -c LIVE "$WORK/fixture.out") if [ "$live" = 6 ]; then ok "heredoc bodies, multi-line strings and continuations are left alone (6/6)" diff --git a/general/scripts/strip-shell-comments.awk b/general/scripts/strip-shell-comments.awk index 72ee986800..f544bfaa45 100644 --- a/general/scripts/strip-shell-comments.awk +++ b/general/scripts/strip-shell-comments.awk @@ -1,4 +1,5 @@ -# Drop whole-line comments and blank lines from a POSIX shell script. +# Drop whole-line comments from a POSIX shell script. +# Keep blank lines to preserve readability. See #2386. # # Comments are worth writing and worth keeping in the tree, but every byte of # them is also flashed to an 8MB camera. sysupgrade alone reached 52KB, 57% of