🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.utils.bug
Article #1144

sed (my suggested fix is broke)

#1144
From: Mike Sangrey
Date: Mon, 21 Dec 1992 04:59
64 lines
2098 bytes
This message refers to the patch that dealt with what I think is a bug with
   sed -n s/foo/bar/p

Specifically, in sed.c the change was

	  if (cur_cmd->x.cmd_regex.flags & S_WRITE_BIT
	      && !no_default_output)
	    ck_fwrite (line.text, 1, line.length,
		       cur_cmd->x.cmd_regex.wio_file);
	  if (cur_cmd->x.cmd_regex.flags & S_PRINT_BIT
-	      && !no_default_output)
	    ck_fwrite (line.text, 1, line.length, stdout);
	  break;

---- to ----

	  if (cur_cmd->x.cmd_regex.flags & S_WRITE_BIT
	      && !no_default_output)
	    ck_fwrite (line.text, 1, line.length,
		       cur_cmd->x.cmd_regex.wio_file);
	  if (cur_cmd->x.cmd_regex.flags & S_PRINT_BIT
+	      || !no_default_output)
	    ck_fwrite (line.text, 1, line.length, stdout);
	  break;


A few days ago I made this suggestion.  However, my simple fix causes
something else to break.  

For example:

----------------------
#!/bin/sh

az=abcdefghijklmnopqrstuvwxyz
AZ=ABCDEFGHIJKLMNOPQRSTUVWXYZ

/bin/sed -e "
	y/$AZ/$az/
	h
	y/$az/$AZ/
	G
        s/\(.\).*\n./\1/
"
----------------------

echo fooHaaHAA | this-script         # gives Foohaahaa with*out* my patch

And that is as it should be, at least with my understanding.  With my
patch, it gives two lines:

Foohaahaa
Foohaahaa

Hope this helps. 
Hope that any previous help that I helped with didn't unhelp.

Thanks again.

mike@sojurn.lns.pa.us
-- 
  |  UUCP-stuff:  ...!pitt!devon!sojurn!mike | "Disk space ...               |
  |  Internet  :  mike@sojurn.lns.pa.us      |      the final frontier."     |
  |  Fast-stuff:  (717) 396-9897             |                               |
Technical Details
Message-ID: <m0n3obE-0003RBM@sojurn.lns.pa.us>
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!sojurn.lns.pa.US!mike

Show Full Headers
Complete Article Headers
Newsgroups: gnu.utils.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!sojurn.lns.pa.US!mike
From: mike@sojurn.lns.pa.US (Mike Sangrey)
Subject: sed (my suggested fix is broke)
Message-ID: <m0n3obE-0003RBM@sojurn.lns.pa.us>
Sender: gnulists@ai.mit.edu
Organization: GNUs Not Usenet
Distribution: gnu
Date: Mon, 21 Dec 1992 04:59:14 GMT
Approved: bug-gnu-utils@prep.ai.mit.edu
Lines: 65