Re: [PATCH] expand: Fix trailing newlines processing in backquote expanding

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Herbert,

Do you want any changes to this patch from us? This patch in state "Under Review" more then 8 months.

Regards,
Nikolai

----- Original Message -----
> From: "n merinov" <n.merinov@xxxxxxxxxxxxxxxxxx>
> To: dash@xxxxxxxxxxxxxxx
> Cc: "os" <os@xxxxxxxxxxxxxxxxxx>, "n merinov" <n.merinov@xxxxxxxxxxxxxxxxxx>
> Sent: Monday, April 29, 2019 7:13:37 PM
> Subject: [PATCH] expand: Fix trailing newlines processing in backquote expanding

> According to POSIX.1-2008 we should remove newlines only at the end of
> the substitution. Newlines-only substitions causes dash to remove
> newlines before beggining of the substitution. The following code:
> 
>    cat <<END
>    1
>    $(echo "")
>    2
>    END
> 
> prints "1<newline>2" instead of expected "1<newline><newline>2".
> 
> This patch fixes trailing newlines processing in backquote expanding.
> 
> Signed-off-by: Nikolai Merinov <n.merinov@xxxxxxxxxxxxxxxxxx>
> ---
> src/expand.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/expand.c b/src/expand.c
> index af9cac9..1b1f95e 100644
> --- a/src/expand.c
> +++ b/src/expand.c
> @@ -525,7 +525,7 @@ read:
> 
> 	/* Eat all trailing newlines */
> 	dest = expdest;
> -	for (; dest > (char *)stackblock() && dest[-1] == '\n';)
> +	for (; dest > ((char *)stackblock() + startloc) && dest[-1] == '\n';)
> 		STUNPUTC(dest);
> 	expdest = dest;
> 
> --
> 2.17.1



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux