Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] zsh/system: fix `zsystem flock` optarg parsing
This should probably be pushed before 5.10 release
On Sun, May 11, 2025 at 4:58 PM dana <dana@xxxxxxx> wrote:
>
> this wasn't allowing optargs in the same word:
>
> % zsystem flock -f XYZ =( : )
> % zsystem flock -fXYZ =( : )
> zsystem: flock: unknown option: Z
>
> dana
>
>
> diff --git a/Src/Modules/system.c b/Src/Modules/system.c
> index 929a8b002..f1c0d7042 100644
> --- a/Src/Modules/system.c
> +++ b/Src/Modules/system.c
> @@ -572,7 +572,7 @@ bin_zsystem_flock(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
> /* variable for fd */
> if (optptr[1]) {
> fdvar = optptr + 1;
> - optptr += strlen(fdvar) - 1;
> + optptr += strlen(fdvar);
> } else if (*args) {
> fdvar = *args++;
> }
> @@ -592,7 +592,7 @@ bin_zsystem_flock(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
> /* timeout in seconds */
> if (optptr[1]) {
> optarg = optptr + 1;
> - optptr += strlen(optarg) - 1;
> + optptr += strlen(optarg);
> } else if (!*args) {
> zwarnnam(nam, "flock: option %c requires a numeric timeout",
> opt);
> @@ -622,7 +622,7 @@ bin_zsystem_flock(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
> /* retry interval in seconds */
> if (optptr[1]) {
> optarg = optptr + 1;
> - optptr += strlen(optarg) - 1;
> + optptr += strlen(optarg);
> } else if (!*args) {
> zwarnnam(nam,
> "flock: option %c requires "
>
> diff --git a/Test/V14system.ztst b/Test/V14system.ztst
> index 81253324f..a54d5fa14 100644
> --- a/Test/V14system.ztst
> +++ b/Test/V14system.ztst
> @@ -148,6 +148,14 @@ F:This timing test might fail due to process scheduling issues unrelated to zsh.
> ?elapsed time seems OK
> F:This timing test might fail due to process scheduling issues unrelated to zsh.
>
> + zsystem flock -t 1 -i 1 -f XYZ $tst_dir/file
> + echo $XYZ
> + zsystem flock -t1 -i1 -fZYX $tst_dir/file
> + echo $ZYX
> +0:regression: zsystem flock optarg parsing
> +*><->
> +*><->
> +
> unset chars REPLY
> print -n a few words | sysread -i 0 -c chars
> ret=$?
>
Messages sorted by:
Reverse Date,
Date,
Thread,
Author