[PATCH v2 0/2] Support for `read -d<delim>`
Denys Vlasenko
vda.linux at googlemail.com
Wed Aug 9 12:05:46 UTC 2017
Applied, thanks.
Does git testsuite work now with current git?
On Tue, Aug 8, 2017 at 4:46 PM, Johannes Schindelin
<johannes.schindelin at gmx.de> wrote:
> This feature is used by Git's test suite. That is the incentive. It was
> also pretty to implement, so why not ;-)
>
> Changes since v1:
>
> - split into two patches, one for ash, one for hush, to make it easier
> to drop the hush one if so desired.
>
> - hide the feature behind the *_BASH_COMPAT knobs, as suggested by
> Kang-Che Sung.
>
>
> Johannes Schindelin (2):
> ash: implement -d DELIM option for `read`
> hush: implement -d DELIM option for `read`
>
> shell/ash.c | 19 ++++++++++++++++---
> shell/hush.c | 24 ++++++++++++++++++++++--
> shell/shell_common.c | 10 +++++++---
> shell/shell_common.h | 3 ++-
> 4 files changed, 47 insertions(+), 9 deletions(-)
>
>
> base-commit: 73adef14b25533b71238362da75bfb482d43d98b
> Published-As: https://github.com/dscho/busybox-w32/releases/tag/busybox-read-d-v2
> Fetch-It-Via: git fetch https://github.com/dscho/busybox-w32 busybox-read-d-v2
>
> Interdiff vs v1:
> diff --git a/shell/ash.c b/shell/ash.c
> index e2d98584a..4b0896573 100644
> --- a/shell/ash.c
> +++ b/shell/ash.c
> @@ -189,6 +189,8 @@
> #define BASH_HOSTNAME_VAR ENABLE_ASH_BASH_COMPAT
> #define BASH_SHLVL_VAR ENABLE_ASH_BASH_COMPAT
> #define BASH_XTRACEFD ENABLE_ASH_BASH_COMPAT
> +#define BASH_READ_D ENABLE_ASH_BASH_COMPAT
> +#define IF_BASH_READ_D IF_ASH_BASH_COMPAT
>
> #if defined(__ANDROID_API__) && __ANDROID_API__ <= 24
> /* Bionic at least up to version 24 has no glob() */
> @@ -13415,7 +13417,7 @@ readcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
> char *opt_p = NULL;
> char *opt_t = NULL;
> char *opt_u = NULL;
> - char *opt_d = NULL;
> + IF_BASH_READ_D(char *opt_d = NULL;)
> int read_flags = 0;
> const char *r;
> int i;
> @@ -13440,9 +13442,11 @@ readcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
> case 'u':
> opt_u = optionarg;
> break;
> +#if BASH_READ_D
> case 'd':
> opt_d = optionarg;
> break;
> +#endif
> default:
> break;
> }
> @@ -13461,7 +13465,11 @@ readcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
> opt_p,
> opt_t,
> opt_u,
> +#if BASH_READ_D
> opt_d
> +#else
> + NULL
> +#endif
> );
> INT_ON;
>
> diff --git a/shell/hush.c b/shell/hush.c
> index e5e59c949..278b44a9c 100644
> --- a/shell/hush.c
> +++ b/shell/hush.c
> @@ -352,6 +352,7 @@
> #define BASH_SOURCE ENABLE_HUSH_BASH_COMPAT
> #define BASH_HOSTNAME_VAR ENABLE_HUSH_BASH_COMPAT
> #define BASH_TEST2 (ENABLE_HUSH_BASH_COMPAT && ENABLE_HUSH_TEST)
> +#define BASH_READ_D ENABLE_HUSH_BASH_COMPAT
>
>
> /* Build knobs */
> @@ -9434,15 +9435,27 @@ static int FAST_FUNC builtin_read(char **argv)
> char *opt_p = NULL;
> char *opt_t = NULL;
> char *opt_u = NULL;
> +#if BASH_READ_D
> char *opt_d = NULL;
> +#endif
> const char *ifs;
> int read_flags;
>
> /* "!": do not abort on errors.
> * Option string must start with "sr" to match BUILTIN_READ_xxx
> */
> - read_flags = getopt32(argv, "!srn:p:t:u:d:", &opt_n, &opt_p, &opt_t,
> - &opt_u, &opt_d);
> + read_flags = getopt32(argv,
> +#if BASH_READ_D
> + "!srn:p:t:u:d:",
> +#else
> + "!srn:p:t:u:",
> +#endif
> + &opt_n, &opt_p, &opt_t,
> + &opt_u
> +#if BASH_READ_D
> + , &opt_d
> +#endif
> + );
> if (read_flags == (uint32_t)-1)
> return EXIT_FAILURE;
> argv += optind;
> @@ -9457,7 +9470,11 @@ static int FAST_FUNC builtin_read(char **argv)
> opt_p,
> opt_t,
> opt_u,
> +#if BASH_READ_D
> opt_d
> +#else
> + NULL
> +#endif
> );
>
> if ((uintptr_t)r == 1 && errno == EINTR) {
> --
> 2.14.0.windows.1.2.g0f3342804fc
>
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
More information about the busybox
mailing list