Bug 18474

Summary: sed i\ does not append newline
Product: Base System Reporter: nsayer <nsayer>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.0-STABLE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description nsayer freebsd_committer freebsd_triage 2000-05-10 00:50:00 UTC
On FreeBSD, the output of script 'bar' is

1
2
foo3
4
5

On every other OS I have tried, the output is

1
2
foo
3
4
5

How-To-Repeat: 
See above.
Comment 1 Nick Sayer 2000-05-10 18:45:55 UTC
The patch above breaks sed -f. Instead, this patch explicitely
appends a \n to -e arguments.

--- main.c.orig	Wed May 10 10:31:02 2000
+++ main.c	Wed May 10 10:33:36 2000
@@ -114,6 +114,7 @@
 	char *argv[];
 {
 	int c, fflag;
+	char *temp_arg;
 
 	(void) setlocale(LC_ALL, "");
 
@@ -125,7 +126,10 @@
 			break;
 		case 'e':
 			eflag = 1;
-			add_compunit(CU_STRING, optarg);
+			temp_arg=malloc(strlen(optarg)+2);
+			strcpy(temp_arg,optarg);
+			strcat(temp_arg,"\n");
+			add_compunit(CU_STRING, temp_arg);
 			break;
 		case 'f':
 			fflag = 1;
Comment 2 nsayer freebsd_committer freebsd_triage 2000-05-11 18:03:39 UTC
State Changed
From-To: open->closed

Committed (src/usr.sbin/sed/main.c, v1.11).