Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Strange escaped < > behaviour



On Wed, Mar 11, 2009 at 4:22 AM, Jerry Rocteur wrote:
> Hi,
>
> 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
>
> The easy way to fix it is to remove the back slash in front of the < and >
>
> However this is VERY annoying.
>
> Why does the above give us ULOG and why does this differ from the KSH and PDKSH.

I'm going to go *way* out on a limb with my assumptions here, but,
here goes: You're clearly doing this on a non-linux unix, since Linux
would use gnu sed, where \< and \> are special and different from <
and >.  If you were on Linux, your script would never have worked.
So, my huge assumption would be to guess that you probably put paths
to gnu versions of tools in your path.  I know I did the last time I
was stuck using Solaris.  So, my best guess is that your $PATH is set
differently on zsh than in ksh or pdksh, causing zsh to call a version
of sed where \< and \> match word boundaries, instead of matching <
and >.  Change your $PATH, or use an absolute path to the sed binary
that works with pdksh, and I'm guessing things will just work.

~Matt



Messages sorted by: Reverse Date, Date, Thread, Author