[PATCH 1/5] ash: allow newline after variable name in for loop
Denys Vlasenko
vda.linux at googlemail.com
Thu Oct 29 18:34:19 UTC 2015
Applied, thanks
On Mon, Aug 3, 2015 at 2:46 PM, Ron Yorston <rmy at pobox.com> wrote:
> Newline is a valid delimiter between the variable name and `in`
> keyword in for loops.
>
> Based on commit 22e8fb4 from git://git.kernel.org/pub/scm/utils/dash/dash.git
> by Herbert Xu.
>
> function old new delta
> parse_command 1568 1563 -5
> ------------------------------------------------------------------------------
> (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-5) Total: -5 bytes
>
> Signed-off-by: Ron Yorston <rmy at pobox.com>
> ---
> shell/ash.c | 4 ++--
> shell/ash_test/ash-misc/for.right | 1 +
> shell/ash_test/ash-misc/for.tests | 5 +++++
> 3 files changed, 8 insertions(+), 2 deletions(-)
> create mode 100644 shell/ash_test/ash-misc/for.right
> create mode 100755 shell/ash_test/ash-misc/for.tests
>
> diff --git a/shell/ash.c b/shell/ash.c
> index f6190c3..450a42f 100644
> --- a/shell/ash.c
> +++ b/shell/ash.c
> @@ -10914,7 +10914,7 @@ parse_command(void)
> n1 = stzalloc(sizeof(struct nfor));
> n1->type = NFOR;
> n1->nfor.var = wordtext;
> - checkkwd = CHKKWD | CHKALIAS;
> + checkkwd = CHKNL | CHKKWD | CHKALIAS;
> if (readtoken() == TIN) {
> app = ≈
> while (readtoken() == TWORD) {
> @@ -10941,7 +10941,7 @@ parse_command(void)
> * Newline or semicolon here is optional (but note
> * that the original Bourne shell only allowed NL).
> */
> - if (lasttoken != TNL && lasttoken != TSEMI)
> + if (lasttoken != TSEMI)
> tokpushback = 1;
> }
> checkkwd = CHKNL | CHKKWD | CHKALIAS;
> diff --git a/shell/ash_test/ash-misc/for.right b/shell/ash_test/ash-misc/for.right
> new file mode 100644
> index 0000000..d86bac9
> --- /dev/null
> +++ b/shell/ash_test/ash-misc/for.right
> @@ -0,0 +1 @@
> +OK
> diff --git a/shell/ash_test/ash-misc/for.tests b/shell/ash_test/ash-misc/for.tests
> new file mode 100755
> index 0000000..4889a9f
> --- /dev/null
> +++ b/shell/ash_test/ash-misc/for.tests
> @@ -0,0 +1,5 @@
> +for i
> +in OK
> +do
> + echo $i
> +done
> --
> 2.4.3
>
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
More information about the busybox
mailing list