Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Strange escaped < > behaviour
- X-seq: zsh-users 13897
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Strange escaped < > behaviour
- Date: Wed, 11 Mar 2009 09:56:08 +0000
- In-reply-to: <57016.153.98.68.197.1236759758.squirrel@xxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <57016.153.98.68.197.1236759758.squirrel@xxxxxxxxxxxxxxxxxxx>
"Jerry Rocteur" wrote:
> We have a bunch of scripts that work on KSH and PDKSH like this:
>
>echo ' ULOGPFX = "<WORK_DIR>/ULOG"' | sed 's/.*\<\(.*\)\>.*/\1/'
> WORK_DIR
>
> Don't ask me why the escaped the < and > above but the scripts have been like
> this for a LONG LONG time!
>
> Now with ZSH I get this behaviour
>
>echo ' ULOGPFX = "<WORK_DIR>/ULOG"' | sed 's/.*\<\(.*\)\>.*/\1/'
> ULOG
(This is basically the same answer as Matt just gave but I'll send it
anyway since I put in slightly different detail.)
There's nothing in zsh that could possibly make a difference, and in
bash on my system it gives me ULOG too. This is because "\<" and "\>"
in certain versions of sed (in particular GNU) match the start and end
of a word. See the "Regex syntax clashes" section in the "Reporting
bugs" node of the GNU sed manual.
I strongly suspect it's either calling a different version of sed, or
some environment variable is changing the behaviour. I can't see any
environment variable relevant to GNU sed, however: there's some mention
of POSIXLY_CORRECT in the manual, but it didn't seem to have an effect
in this case.
If you want to avoid this generally, you do need to remove the
backslashes from before the "<" and ">", in which case they are
guaranteed not to do anything special.
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
Messages sorted by:
Reverse Date,
Date,
Thread,
Author