commit ade87e07baf2b5315b9e56dadfb26117cc567a95
parent 21016570f4b42a0814134c43e8e27c388856ee5e
Author: hhvn <dev@hhvn.uk>
Date: Sun, 2 Jan 2022 13:36:00 +0000
parse.y rc.1: support ifs-list with single backtick
Diffstat:
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/parse.y b/parse.y
@@ -150,6 +150,8 @@ comword : '$' sword { $$ = mk(nVar,$2); }
| FLAT sword { $$ = mk(nFlat, $2); }
| '`' sword { $$ = mk(nBackq,nolist,$2); }
| '`' brace { $$ = mk(nBackq,nolist,$2); }
+ | '`' word brace { $$ = mk(nBackq,$2,$3); }
+ | '`' word sword { $$ = mk(nBackq,$2,$3); }
| BACKBACK word brace { $$ = mk(nBackq,$2,$3); }
| BACKBACK word sword { $$ = mk(nBackq,$2,$3); }
| '(' nlwords ')' { $$ = $2; }
diff --git a/rc.1 b/rc.1
@@ -1220,7 +1220,7 @@ In order to override the value of
for a single backquote
substitution, use:
.Ds
-.Cr "\`\` (ifs-list) { command }"
+.Cr "\`(ifs-list){ command }"
.De
.PP
.Cr $ifs
@@ -1228,7 +1228,7 @@ will be temporarily ignored and the command's output will be split as specified
the list following the double backquote.
For example:
.Ds
-.Cr "\`\` ($nl :) {cat /etc/passwd}"
+.Cr "\`($nl :){cat /etc/passwd}"
.De
.PP
splits up
@@ -1244,7 +1244,7 @@ to contain the newline character, and
to contain the tab character. Thus, if you want to process everything in the
current directory, but in a random order, you could use:
.Ds
-.Cr "for (f in \`\` $nl {ls | shuf}) { ... process $f }"
+.Cr "for (f in \`$nl{ls | shuf}) { ... process $f }"
.De
.PP
This will correctly handle filenames that contain spaces.