sed on OS4 is buggy
Posted: Thu Aug 28, 2014 10:53 am
Hi
I have been struggling quite a bit with something that seemed simple enough (well, relative to sed that is). I want to extract the second "x:...." up to the next "x:..".
Have a look at this (run from sh):
Notice the tiny difference? An additional space after \1. The space can be anywhere but has to be included to make sed print correctly. Other text in the output section does not help, there has to be a space, like /A \1/ or /\1hello world/. If it is the intended behavior of sed, then please instruct me how to make sed print the desired match without any space in the output.
Now using -re to simplify things:
I believe this is the reason why TeTeX is not working on OS4 (anymore). It can't generate fonts because it can't extract paths properly. I was trying to patch-fix the scripts but then realized there has to be a bug in sed.
> which sed
Project:SDK/Local/C/sed
> sed --version
GNU sed version 4.1.5
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,
to the extent permitted by law.
I have been struggling quite a bit with something that seemed simple enough (well, relative to sed that is). I want to extract the second "x:...." up to the next "x:..".
Have a look at this (run from sh):
Code: Select all
> echo "x:abc/def/x:ghi/jkl/x:mno/pqr" | sed 's/x:[a-z\/]*x:ghi\([^:]*\)\/x:.*/\1/'
x:abc/def/x:ghi/jkl/x:mno/pqr
(match (or print) failed)
> echo "x:abc/def/x:ghi/jkl/x:mno/pqr" | sed 's/x:[a-z\/]*x:ghi\([^:]*\)\/x:.*/\1 /'
/jkl
(I got my output but it has a trailing space)
Now using -re to simplify things:
Code: Select all
> echo "x:abc/def/x:ghi/jkl/x:mno/pqr" | sed -re 's/x:[a-z\/]+x:ghi([^:]+)\/x:.*/\1/'
/jklno/pqr
(what happened here?? (if I add a space aroung \1 it's fine))
> which sed
Project:SDK/Local/C/sed
> sed --version
GNU sed version 4.1.5
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,
to the extent permitted by law.