[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: Re: [PATCH 1/3] shell: Fix "read -d ''" behavior
From: Denys Vlasenko <vda.linux () googlemail ! com>
Date: 2020-07-31 16:43:27
Message-ID: CAK1hOcM4nqRzXNzWywg7w2FBDNPSXns1cgP5n9qBECMafRdn6A () mail ! gmail ! com
[Download RAW message or body]
Applied, thanks!
On Mon, Jun 29, 2020 at 6:28 PM Christian Eggers <ceggers@arri.de> wrote:
>
> With bash's read builtin it is possible to read from a file (e.g.
> device-tree) until the first '\0' character:
>
> IFS= read -r -d '' VARIABLE < file
>
> In busybox ash the -d extension is also implemented, but checking the
> read character for '\0' has to be performed after comparing with the
> delimiter.
>
> Signed-off-by: Christian Eggers <ceggers@arri.de>
> ---
> shell/shell_common.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/shell/shell_common.c b/shell/shell_common.c
> index 12c4a073c..42c4c9c97 100644
> --- a/shell/shell_common.c
> +++ b/shell/shell_common.c
> @@ -209,8 +209,6 @@ shell_builtin_read(struct builtin_read_params *params)
> }
>
> c = buffer[bufpos];
> - if (c == '\0')
> - continue;
> if (!(read_flags & BUILTIN_READ_RAW)) {
> if (backslash) {
> backslash = 0;
> @@ -225,6 +223,8 @@ shell_builtin_read(struct builtin_read_params *params)
> }
> if (c == delim) /* '\n' or -d CHAR */
> break;
> + if (c == '\0')
> + continue;
>
> /* $IFS splitting. NOT done if we run "read"
> * without variable names (bash compat).
> --
> Christian Eggers
> Embedded software developer
>
> Arnold & Richter Cine Technik GmbH & Co. Betriebs KG
> Sitz: Muenchen - Registergericht: Amtsgericht Muenchen - Handelsregisternummer: HRA 57918
> Persoenlich haftender Gesellschafter: Arnold & Richter Cine Technik GmbH
> Sitz: Muenchen - Registergericht: Amtsgericht Muenchen - Handelsregisternummer: HRB 54477
> Geschaeftsfuehrer: Dr. Michael Neuhaeuser; Stephan Schenk; Walter Trauninger; Markus Zeiler
>
> _______________________________________________
> busybox mailing list
> busybox@busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic