1
From: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
2
Date: Thu, 19 Apr 2018 18:16:12 +0800
4
> ash originally had support for omitting the fork when expanding a
5
> builtin in backquotes. dash has gradually been removing this support,
6
> most recently in commit 66b614e29038e31745c4a5d296f64f8d64f5c377
7
> ("[EVAL] Remove unused EV_BACKCMD flag").
9
> Some traces still remain, however. Remove:
11
> - the buf and nleft elements of the backcmd structure;
12
> - a misleading comment regarding handling of builtins.
14
> Signed-off-by: Ron Yorston <rmy@xxxxxxxxxxxx>
16
Unfortunately we may need this at some point in the future due
17
to changes in POSIX. So let's keep it around for now until we
18
get things such as `jobs -p` to work.
20
*************************************
22
From: Ron Yorston <rmy@xxxxxxxxxxxx>
23
Date: Thu, 19 Apr 2018 17:18:47 +0100
25
>Unfortunately we may need this at some point in the future due
26
>to changes in POSIX. So let's keep it around for now until we
27
>get things such as `jobs -p` to work.
31
Something even more trivial I noticed later: the TRACE at the end of
32
expbackq incorrectly refers to the function as evalbackq.
34
*************************************
36
Date: Tue, 10 Apr 2018 13:23:35 +0100
37
From: Ron Yorston <rmy@pobox.com>
38
To: busybox@busybox.net
39
Subject: [PATCH] ash: remove unnecessary code in backquote expansion
41
Some traces remain of ash's ancient support for omitting the fork when
42
expanding a builtin command in backquotes.
46
- the buf and nleft elements of the backcmd structure;
47
- a misleading comment regarding handling of builtins.
49
I've submitted a similar patch to dash.
51
Signed-off-by: Ron Yorston <rmy@pobox.com>
53
shell/ash.c | 37 +++++++++----------------------------
54
1 file changed, 9 insertions(+), 28 deletions(-)
56
diff --git a/shell/ash.c b/shell/ash.c
57
index 45c747dbc..6f1458722 100644
60
@@ -6356,15 +6356,12 @@ exptilde(char *startp, char *p, int flags)
64
- * Execute a command inside back quotes. If it's a builtin command, we
65
- * want to save its output in a block obtained from malloc. Otherwise
66
- * we fork off a subprocess and get the output of the command via a pipe.
67
- * Should be called with interrupts off.
68
+ * Execute a command inside back quotes. We fork off a subprocess and
69
+ * get the output of the command via a pipe. Should be called with
72
struct backcmd { /* result of evalbackcmd */
73
int fd; /* file descriptor to read from */
74
- int nleft; /* number of chars in buffer */
75
- char *buf; /* buffer */
76
struct job *jp; /* job structure for command */
79
@@ -6394,8 +6391,6 @@ evalbackcmd(union node *n, struct backcmd *result)
88
@@ -6432,8 +6427,7 @@ evalbackcmd(union node *n, struct backcmd *result)
92
- TRACE(("evalbackcmd done: fd=%d buf=0x%x nleft=%d jp=0x%x\n",
93
- result->fd, result->buf, result->nleft, result->jp));
94
+ TRACE(("evalbackcmd done: fd=%d jp=0x%x\n", result->fd, result->jp));
98
@@ -6445,7 +6439,6 @@ expbackq(union node *cmd, int flag)
105
int syntax = flag & EXP_QUOTED ? DQSYNTAX : BASESYNTAX;
106
@@ -6457,24 +6450,12 @@ expbackq(union node *cmd, int flag)
107
evalbackcmd(cmd, &in);
108
popstackmark(&smark);
115
- memtodest(p, i, syntax, flag & QUOTES_ESC);
119
- i = nonblock_immune_read(in.fd, buf, sizeof(buf));
120
- TRACE(("expbackq: read returns %d\n", i));
128
+ while ((i = nonblock_immune_read(in.fd, buf, sizeof(buf))) > 0) {
129
+ TRACE(("expbackq: read returns %d\n", i));
130
+ memtodest(buf, i, syntax, flag & QUOTES_ESC);
134
back_exitstatus = waitforjob(in.jp);