zsh-users
 help / color / mirror / code / Atom feed
* Interesting zsh behaviour regarding awk and backslash
@ 2011-09-27 11:42 İsmail Dönmez
  2011-09-27 11:54 ` Jérémie Roquet
  2011-09-27 13:51 ` Mikael Magnusson
  0 siblings, 2 replies; 10+ messages in thread
From: İsmail Dönmez @ 2011-09-27 11:42 UTC (permalink / raw)
  To: Zsh Users

[-- Attachment #1: Type: text/plain, Size: 270 bytes --]

Hi;

gawk 3.1.8

bash:

[~]> echo '\\' | gawk '{gsub("\\\\","\\\\",$0); print($0);}'
\\\\

zsh 4.3.12-dev-1

[~]> echo '\\' | gawk '{gsub("\\\\","\\\\",$0); print($0);}'
\\

Ideas?

P.S: gaw 4.0.0 is buggy with this gsub command and output will differ.

Regards,
ismail

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Interesting zsh behaviour regarding awk and backslash
  2011-09-27 11:42 Interesting zsh behaviour regarding awk and backslash İsmail Dönmez
@ 2011-09-27 11:54 ` Jérémie Roquet
  2011-09-27 11:55   ` İsmail Dönmez
  2011-09-27 13:48   ` Bart Schaefer
  2011-09-27 13:51 ` Mikael Magnusson
  1 sibling, 2 replies; 10+ messages in thread
From: Jérémie Roquet @ 2011-09-27 11:54 UTC (permalink / raw)
  To: Zsh Users; +Cc: İsmail Dönmez

Hi İsmail,

2011/9/27 İsmail Dönmez <ismail@namtrac.org>:
> gawk 3.1.8
>
> bash:
>
> [~]> echo '\\' | gawk '{gsub("\\\\","\\\\",$0); print($0);}'
> \\\\
>
> zsh 4.3.12-dev-1
>
> [~]> echo '\\' | gawk '{gsub("\\\\","\\\\",$0); print($0);}'
> \\
>
> Ideas?

Why bother with gawk?

bash$ echo '\\'
\\
zsh$ echo '\\'
\

:p

Best regards,

-- 
Jérémie


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Interesting zsh behaviour regarding awk and backslash
  2011-09-27 11:54 ` Jérémie Roquet
@ 2011-09-27 11:55   ` İsmail Dönmez
  2011-09-27 13:48   ` Bart Schaefer
  1 sibling, 0 replies; 10+ messages in thread
From: İsmail Dönmez @ 2011-09-27 11:55 UTC (permalink / raw)
  To: Zsh Users

[-- Attachment #1: Type: text/plain, Size: 560 bytes --]

Hi;

On Tue, Sep 27, 2011 at 1:54 PM, Jérémie Roquet <arkanosis@gmail.com> wrote:

> Hi İsmail,
>
> 2011/9/27 İsmail Dönmez <ismail@namtrac.org>:
> > gawk 3.1.8
> >
> > bash:
> >
> > [~]> echo '\\' | gawk '{gsub("\\\\","\\\\",$0); print($0);}'
> > \\\\
> >
> > zsh 4.3.12-dev-1
> >
> > [~]> echo '\\' | gawk '{gsub("\\\\","\\\\",$0); print($0);}'
> > \\
> >
> > Ideas?
>
> Why bother with gawk?
>
> bash$ echo '\\'
> \\
> zsh$ echo '\\'
> \
>

Ah cool, I was working on a gawk bug when I noticed this :-)

Regards,
ismail

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Interesting zsh behaviour regarding awk and backslash
  2011-09-27 11:54 ` Jérémie Roquet
  2011-09-27 11:55   ` İsmail Dönmez
@ 2011-09-27 13:48   ` Bart Schaefer
  2011-09-27 18:11     ` Stephane Chazelas
  1 sibling, 1 reply; 10+ messages in thread
From: Bart Schaefer @ 2011-09-27 13:48 UTC (permalink / raw)
  To: Zsh Users; +Cc: Ismail Donmez

On Sep 27,  1:54pm, Jeremie Roquet wrote:
}
} Why bother with gawk?
} 
} bash$ echo '\\'
} \\
} zsh$ echo '\\'
} \

This isn't quoting behavior, it's "echo" behavior.  If you tell zsh to
act like a standard shell, it does:

% ARGV0=sh zsh -f
$ echo '\\'
\\
$  set -o | grep echo
nobsdecho             off
$ 


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Interesting zsh behaviour regarding awk and backslash
  2011-09-27 11:42 Interesting zsh behaviour regarding awk and backslash İsmail Dönmez
  2011-09-27 11:54 ` Jérémie Roquet
@ 2011-09-27 13:51 ` Mikael Magnusson
  2011-09-27 13:54   ` İsmail Dönmez
  1 sibling, 1 reply; 10+ messages in thread
From: Mikael Magnusson @ 2011-09-27 13:51 UTC (permalink / raw)
  To: İsmail Dönmez; +Cc: Zsh Users

On 27 September 2011 13:42, İsmail Dönmez <ismail@namtrac.org> wrote:
> Hi;
>
> gawk 3.1.8
>
> bash:
>
> [~]> echo '\\' | gawk '{gsub("\\\\","\\\\",$0); print($0);}'
> \\\\
>
> zsh 4.3.12-dev-1
>
> [~]> echo '\\' | gawk '{gsub("\\\\","\\\\",$0); print($0);}'
> \\
>
> Ideas?

setopt bsdecho (it changes whether -e or -E is the default mode).

-- 
Mikael Magnusson


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Interesting zsh behaviour regarding awk and backslash
  2011-09-27 13:51 ` Mikael Magnusson
@ 2011-09-27 13:54   ` İsmail Dönmez
  2011-09-27 14:18     ` Frank Terbeck
  2011-09-27 14:20     ` Bart Schaefer
  0 siblings, 2 replies; 10+ messages in thread
From: İsmail Dönmez @ 2011-09-27 13:54 UTC (permalink / raw)
  To: Zsh Users

[-- Attachment #1: Type: text/plain, Size: 589 bytes --]

Hi;

On Tue, Sep 27, 2011 at 3:51 PM, Mikael Magnusson <mikachu@gmail.com> wrote:

> On 27 September 2011 13:42, İsmail Dönmez <ismail@namtrac.org> wrote:
> > Hi;
> >
> > gawk 3.1.8
> >
> > bash:
> >
> > [~]> echo '\\' | gawk '{gsub("\\\\","\\\\",$0); print($0);}'
> > \\\\
> >
> > zsh 4.3.12-dev-1
> >
> > [~]> echo '\\' | gawk '{gsub("\\\\","\\\\",$0); print($0);}'
> > \\
> >
> > Ideas?
>
> setopt bsdecho (it changes whether -e or -E is the default mode).
>

Thanks that works,  any reason this is not on by default for sh
compatibility though?

Regards.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Interesting zsh behaviour regarding awk and backslash
  2011-09-27 13:54   ` İsmail Dönmez
@ 2011-09-27 14:18     ` Frank Terbeck
  2011-09-27 14:20     ` Bart Schaefer
  1 sibling, 0 replies; 10+ messages in thread
From: Frank Terbeck @ 2011-09-27 14:18 UTC (permalink / raw)
  To: Zsh Users

İsmail Dönmez wrote:
> On Tue, Sep 27, 2011 at 3:51 PM, Mikael Magnusson <mikachu@gmail.com> wrote:
>> On 27 September 2011 13:42, İsmail Dönmez <ismail@namtrac.org> wrote:
[...]
>> > Ideas?
>>
>> setopt bsdecho (it changes whether -e or -E is the default mode).
>>
>
> Thanks that works,  any reason this is not on by default for sh
> compatibility though?

You can't really portable with `echo'. Even the POSIX section about
`echo' explicitly says something like "For portable applications, use
`printf' instead.".

Regards, Frank

-- 
In protocol design, perfection has been reached not when there is
nothing left to add, but when there is nothing left to take away.
                                                  -- RFC 1925


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Interesting zsh behaviour regarding awk and backslash
  2011-09-27 13:54   ` İsmail Dönmez
  2011-09-27 14:18     ` Frank Terbeck
@ 2011-09-27 14:20     ` Bart Schaefer
  2011-09-27 14:25       ` İsmail Dönmez
  1 sibling, 1 reply; 10+ messages in thread
From: Bart Schaefer @ 2011-09-27 14:20 UTC (permalink / raw)
  To: Zsh Users

On Sep 27,  3:54pm, Ismail Donmez wrote:
}
} Thanks that works,  any reason this is not on by default for sh
} compatibility though?

Because zsh is quite deliberately not sh compatible by default?


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Interesting zsh behaviour regarding awk and backslash
  2011-09-27 14:20     ` Bart Schaefer
@ 2011-09-27 14:25       ` İsmail Dönmez
  0 siblings, 0 replies; 10+ messages in thread
From: İsmail Dönmez @ 2011-09-27 14:25 UTC (permalink / raw)
  To: Zsh Users

[-- Attachment #1: Type: text/plain, Size: 426 bytes --]

Hi;

On Tue, Sep 27, 2011 at 4:20 PM, Bart Schaefer <schaefer@brasslantern.com>wrote:

> On Sep 27,  3:54pm, Ismail Donmez wrote:
> }
> } Thanks that works,  any reason this is not on by default for sh
> } compatibility though?
>
> Because zsh is quite deliberately not sh compatible by default?
>

Well ok, this was from a script which explicitly stated /bin/sh so this is a
non-issue for me, just wondered.

Regards,
ismail

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Interesting zsh behaviour regarding awk and backslash
  2011-09-27 13:48   ` Bart Schaefer
@ 2011-09-27 18:11     ` Stephane Chazelas
  0 siblings, 0 replies; 10+ messages in thread
From: Stephane Chazelas @ 2011-09-27 18:11 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Zsh Users, Ismail Donmez

2011-09-27 06:48:22 -0700, Bart Schaefer:
> On Sep 27,  1:54pm, Jeremie Roquet wrote:
> }
> } Why bother with gawk?
> } 
> } bash$ echo '\\'
> } \\
> } zsh$ echo '\\'
> } \
> 
> This isn't quoting behavior, it's "echo" behavior.  If you tell zsh to
> act like a standard shell, it does:
> 
> % ARGV0=sh zsh -f
> $ echo '\\'
> \\
> $  set -o | grep echo
> nobsdecho             off
> $ 

standard shells *are meant* to output "\", not "\\". bash is not
standard in that regard. So zsh should *not* change its behavior
when called as sh here.

UNIX (POSIX+XSI) mandates the "\", POSIX makes the behavior of
echo unspecified in that case ("\", "\\" and "ambiguous input"
outputs are all acceptable, echo shouldn't be used in POSIX
scripts where the arguments may contain "\" or start with "-n"
(use printf instead))

zsh is not POSIX (and same for bash) in that it doesn't
output "-e" when called as "echo -e".

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html
for the spec.

-- 
Stephane


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2011-09-27 18:17 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-27 11:42 Interesting zsh behaviour regarding awk and backslash İsmail Dönmez
2011-09-27 11:54 ` Jérémie Roquet
2011-09-27 11:55   ` İsmail Dönmez
2011-09-27 13:48   ` Bart Schaefer
2011-09-27 18:11     ` Stephane Chazelas
2011-09-27 13:51 ` Mikael Magnusson
2011-09-27 13:54   ` İsmail Dönmez
2011-09-27 14:18     ` Frank Terbeck
2011-09-27 14:20     ` Bart Schaefer
2011-09-27 14:25       ` İsmail Dönmez

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).