Bug 18474 - sed i\ does not append newline
Summary: sed i\ does not append newline
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 4.0-STABLE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2000-05-10 00:50 UTC by nsayer
Modified: 2000-05-11 18:04 UTC (History)
0 users

See Also:


Attachments
file.diff (290 bytes, patch)
2000-05-10 00:50 UTC, nsayer
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description nsayer freebsd_committer 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 2000-05-11 18:03:39 UTC
State Changed
From-To: open->closed

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