Skip to content

Commit 2124463

Browse files
committed
util (ble/util/writearray): fix a bug in use of gensub in gawk
1 parent 9699ff6 commit 2124463

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

docs/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@
180180
- util (`ble/string#quote-words`): correct the comparison operator (fixup 8bea90d1) (contributed by anoriqq)
181181
- syntax: fix a bug that the completion does not start with `<<[TAB]` `#D2354` 94109ea7
182182
- syntax: fix infinite loop with `case a in \^J` `#D2361` xxxxxxxx
183+
- util (`ble/util/writearray`): fix a bug in use of gensub in gawk (reported by allenap, LeonardoMor, aaronjamt, ionesculiviucristian, Gabryx64) `#D2368`
183184

184185
## Compatibility
185186

lib/test-util.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
ble-import lib/core-test
44

5-
ble/test/start-section 'ble/util' 1274
5+
ble/test/start-section 'ble/util' 1275
66

77
# bleopt
88

@@ -1353,6 +1353,9 @@ function is-global { (builtin readonly "$1"; ! local "$1" 2>/dev/null); }
13531353
fi
13541354
done
13551355
done
1356+
1357+
a=(1 2 3)
1358+
ble/test 'ble/util/writearray --nlfix a' stdout:$'1\n2\n3'
13561359
)
13571360

13581361
# ble/is-function

note.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7852,6 +7852,15 @@ bash_tips
78527852
Done (実装ログ)
78537853
-------------------------------------------------------------------------------
78547854

7855+
2025-07-15
7856+
7857+
* BUG in ble/util/writearray with gawk (reported by allenap, LeonardoMor, aaronjamt, ionesculiviucristian, Gabryx64) [#D2368]
7858+
https://github.com/akinomyoga/ble.sh/issues/603
7859+
7860+
単純に gawk 用の awk スクリプトにミスがあった。今まで発現していなかったのが
7861+
不思議だ。後、エラーが起こった時に何も出力がないのではなく、代わりにそのま
7862+
ま内容を出力してしまうのも不思議だ。取り敢えず修正した。
7863+
78557864
2025-07-02
78567865

78577866
* main: --lib オプションの説明が --help の中になかった [#D2367]

src/util.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2182,7 +2182,7 @@ function ble/util/writearray {
21822182
if (IS_GAWK) {
21832183
decl = gensub(/\[[0-9]+\]="(([^"\\]|\\.)*)" ?/, "\\1\001", "g", decl);
21842184
sub(/\001$/, "", decl);
2185-
decl = gensub(/\\([\\$"`])/, "\\1", decl);
2185+
decl = gensub(/\\([\\$"`])/, "\\1", "g", decl);
21862186
} else {
21872187
# Convert to a ^A-separated list
21882188
gsub(/\[[0-9]+\]="([^"\\]|\\.)*" /, "&\001", decl);

0 commit comments

Comments
 (0)