Shell Change in sed

jrm@

Developer
There was a change in sed, that many people will see for the first time in 11.0.

cat test.sh
Code:
#!/bin/sh

printf "***"
printf "abc" | sed 's/a/z/g'
printf "***"
## FreeBSD 10.3
test.sh
Code:
***zbc
***
## FreeBSD 11.0-RC2
test.sh
Code:
***zbc***
I haven't tested, but it looks like it was the change introduced in revision 269729.
 
Last edited:
Yeah, that's what I was thinking too. The input string doesn't have a newline at the end so the sed(1) output shouldn't either.
 
I agree, in retrospect the old behaviour seems strange. I posted because some of my scripts were expecting the old output and debugging caused me some time.

My use case is probably uncommon though. The output of the script was set as a stream in a common lisp program. Without the newline, functions like this one had trouble.
Code:
(defun set-cpu-stream ()
  (setf *cpu-stream*
	(sb-ext:process-output
	 (sb-ext:run-program "ml_cpu.sh" nil
			     :output :stream
			     :search t
			     :wait nil))))
 
Back
Top