diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2021-06-06 13:00:20 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2021-06-06 13:01:25 +0200 |
commit | 4c4b02c290ce8d24c467964eb25f5bfc8fc98c8b (patch) | |
tree | af8d658dfc834b18594247f3731f5338c526cf42 | |
parent | 457825f77a7c7286647ee888a1000a6bb12ca8fc (diff) | |
download | busybox-w32-4c4b02c290ce8d24c467964eb25f5bfc8fc98c8b.tar.gz busybox-w32-4c4b02c290ce8d24c467964eb25f5bfc8fc98c8b.tar.bz2 busybox-w32-4c4b02c290ce8d24c467964eb25f5bfc8fc98c8b.zip |
ash: save Ron's patch from oblivion
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | shell/ash_remove_unnecessary_code_in_backquote_expansion.patch | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/shell/ash_remove_unnecessary_code_in_backquote_expansion.patch b/shell/ash_remove_unnecessary_code_in_backquote_expansion.patch new file mode 100644 index 000000000..06067dde0 --- /dev/null +++ b/shell/ash_remove_unnecessary_code_in_backquote_expansion.patch | |||
@@ -0,0 +1,135 @@ | |||
1 | From: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> | ||
2 | Date: Thu, 19 Apr 2018 18:16:12 +0800 | ||
3 | |||
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"). | ||
8 | > | ||
9 | > Some traces still remain, however. Remove: | ||
10 | > | ||
11 | > - the buf and nleft elements of the backcmd structure; | ||
12 | > - a misleading comment regarding handling of builtins. | ||
13 | > | ||
14 | > Signed-off-by: Ron Yorston <rmy@xxxxxxxxxxxx> | ||
15 | |||
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. | ||
19 | |||
20 | ************************************* | ||
21 | |||
22 | From: Ron Yorston <rmy@xxxxxxxxxxxx> | ||
23 | Date: Thu, 19 Apr 2018 17:18:47 +0100 | ||
24 | |||
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. | ||
28 | |||
29 | As you wish. | ||
30 | |||
31 | Something even more trivial I noticed later: the TRACE at the end of | ||
32 | expbackq incorrectly refers to the function as evalbackq. | ||
33 | |||
34 | ************************************* | ||
35 | |||
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 | ||
40 | |||
41 | Some traces remain of ash's ancient support for omitting the fork when | ||
42 | expanding a builtin command in backquotes. | ||
43 | |||
44 | Remove: | ||
45 | |||
46 | - the buf and nleft elements of the backcmd structure; | ||
47 | - a misleading comment regarding handling of builtins. | ||
48 | |||
49 | I've submitted a similar patch to dash. | ||
50 | |||
51 | Signed-off-by: Ron Yorston <rmy@pobox.com> | ||
52 | --- | ||
53 | shell/ash.c | 37 +++++++++---------------------------- | ||
54 | 1 file changed, 9 insertions(+), 28 deletions(-) | ||
55 | |||
56 | diff --git a/shell/ash.c b/shell/ash.c | ||
57 | index 45c747dbc..6f1458722 100644 | ||
58 | --- a/shell/ash.c | ||
59 | +++ b/shell/ash.c | ||
60 | @@ -6356,15 +6356,12 @@ exptilde(char *startp, char *p, int flags) | ||
61 | } | ||
62 | |||
63 | /* | ||
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 | ||
70 | + * interrupts off. | ||
71 | */ | ||
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 */ | ||
77 | }; | ||
78 | |||
79 | @@ -6394,8 +6391,6 @@ evalbackcmd(union node *n, struct backcmd *result) | ||
80 | struct job *jp; | ||
81 | |||
82 | result->fd = -1; | ||
83 | - result->buf = NULL; | ||
84 | - result->nleft = 0; | ||
85 | result->jp = NULL; | ||
86 | if (n == NULL) { | ||
87 | goto out; | ||
88 | @@ -6432,8 +6427,7 @@ evalbackcmd(union node *n, struct backcmd *result) | ||
89 | result->jp = jp; | ||
90 | |||
91 | out: | ||
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)); | ||
95 | } | ||
96 | |||
97 | /* | ||
98 | @@ -6445,7 +6439,6 @@ expbackq(union node *cmd, int flag) | ||
99 | struct backcmd in; | ||
100 | int i; | ||
101 | char buf[128]; | ||
102 | - char *p; | ||
103 | char *dest; | ||
104 | int startloc; | ||
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); | ||
109 | |||
110 | - p = in.buf; | ||
111 | - i = in.nleft; | ||
112 | - if (i == 0) | ||
113 | - goto read; | ||
114 | - for (;;) { | ||
115 | - memtodest(p, i, syntax, flag & QUOTES_ESC); | ||
116 | - read: | ||
117 | - if (in.fd < 0) | ||
118 | - break; | ||
119 | - i = nonblock_immune_read(in.fd, buf, sizeof(buf)); | ||
120 | - TRACE(("expbackq: read returns %d\n", i)); | ||
121 | - if (i <= 0) | ||
122 | - break; | ||
123 | - p = buf; | ||
124 | - } | ||
125 | - | ||
126 | - free(in.buf); | ||
127 | if (in.fd >= 0) { | ||
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); | ||
131 | + } | ||
132 | + | ||
133 | close(in.fd); | ||
134 | back_exitstatus = waitforjob(in.jp); | ||
135 | } | ||