[Bug 208554] usr.bin/sed :sed functions 'i' and 'a' discard leading white space

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Tue Apr 5 22:19:04 UTC 2016


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=208554

Bryan Drewery <bdrewery at FreeBSD.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bdrewery at FreeBSD.org

--- Comment #1 from Bryan Drewery <bdrewery at FreeBSD.org> ---

I think this makes sense as otherwise you cannot control whitespace in the
line you are adding.  Reading opengroup there's no mention of eating
whitespace on these commands either.

*However*, we've had this particular behavior forever, since at least r1591.

The removal in NetBSD follows it accidentally being added back in 2014.
The real removal came in 2004:

> commit 39dd7ae9eebb61b8b83c15e441faa17593a5ec8d
> Author: matt <matt>
> Date:   Wed Nov 17 22:17:54 2004 +0000
>
>     When adding text due to an a, c, or i command, don't eat the space(s) at
>     the beginning of the lines since the addition is supposed to be "verbatim".
>     Fix a comment for compile_text indicating it's also used for the 'c' command.
>
> diff --git a/usr.bin/sed/compile.c b/usr.bin/sed/compile.c
> index 4ae0e53..4a185de 100644
> --- a/usr.bin/sed/compile.c
> +++ b/usr.bin/sed/compile.c
> @@ -1,4 +1,4 @@
> -/*	$NetBSD: compile.c,v 1.30 2004/07/09 23:43:07 enami Exp $	*/
> +/*	$NetBSD: compile.c,v 1.31 2004/11/17 22:17:54 matt Exp $	*/
>  
>  /*-
>   * Copyright (c) 1992, 1993
> @@ -72,7 +72,7 @@
>  #if 0
>  static char sccsid[] = "@(#)compile.c	8.2 (Berkeley) 4/28/95";
>  #else
> -__RCSID("$NetBSD: compile.c,v 1.30 2004/07/09 23:43:07 enami Exp $");
> +__RCSID("$NetBSD: compile.c,v 1.31 2004/11/17 22:17:54 matt Exp $");
>  #endif
>  #endif /* not lint */
>  
> @@ -666,7 +666,7 @@ compile_tr(char *p, char **transtab)
>  }
>  
>  /*
> - * Compile the text following an a or i command.
> + * Compile the text following an a, c, or i command.
>   */
>  static char *
>  compile_text(void)
> @@ -681,7 +681,6 @@ compile_text(void)
>  	while (cu_fgets(lbuf, sizeof(lbuf))) {
>  		op = s = text + size;
>  		p = lbuf;
> -		EATSPACE();
>  		for (; *p; p++) {
>  			if (*p == '\\')
>  				p++;


I support removing it, especially since GNU and NetBSD do so as well and
it gives more control to the user.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list