zsh-workers
 help / color / mirror / code / Atom feed
* Bug with sh emulation; shouldn't KSH_TYPESET be set?
@ 2012-01-30 20:21 Felipe Contreras
  2012-01-30 20:43 ` Frank Terbeck
  2012-01-31  9:43 ` Peter Stephenson
  0 siblings, 2 replies; 6+ messages in thread
From: Felipe Contreras @ 2012-01-30 20:21 UTC (permalink / raw)
  To: zsh-workers; +Cc: Felipe Contreras

Hi,

This works on bash

---
_test ()
{
	local t=$(echo foo --bar)
}
_test
---

But not in zsh, with sh emulation. Enabling KSH_TYPESET makes it work.

Shouldn't it be enabled with sh emulation?

BTW. What exactly is 'emulate sh' supposed to emulate? I would like to
run that shell to check for compatibility issues, and apparently it's
not bash.

Cheers.

-- 
Felipe Contreras


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

* Re: Bug with sh emulation; shouldn't KSH_TYPESET be set?
  2012-01-30 20:21 Bug with sh emulation; shouldn't KSH_TYPESET be set? Felipe Contreras
@ 2012-01-30 20:43 ` Frank Terbeck
  2012-01-30 21:46   ` Felipe Contreras
  2012-01-31  9:43 ` Peter Stephenson
  1 sibling, 1 reply; 6+ messages in thread
From: Frank Terbeck @ 2012-01-30 20:43 UTC (permalink / raw)
  To: Felipe Contreras; +Cc: zsh-workers

Felipe Contreras wrote:
[...]
> 	local t=$(echo foo --bar)
[...]
> But not in zsh, with sh emulation. Enabling KSH_TYPESET makes it work.
>
> Shouldn't it be enabled with sh emulation?
>
> BTW. What exactly is 'emulate sh' supposed to emulate? I would like to
> run that shell to check for compatibility issues, and apparently it's
> not bash.

"emulate sh" is POSIX shell emulation (we did amend this mode in the
past to work as much as possible as POSIX describes). Neither typeset
nor local are part of POSIX (at least not SUSv3 - I don't know about
v4).

So, I don't think it should be enabled.

FWIW, dash and posh behave like zsh's sh-mode here. Ksh93 doesn't work
at all, because it has no `local' (only typeset). Mksh, pdksh and bash
work like KSH_TYPESET was set in zsh.

Regards, Frank


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

* Re: Bug with sh emulation; shouldn't KSH_TYPESET be set?
  2012-01-30 20:43 ` Frank Terbeck
@ 2012-01-30 21:46   ` Felipe Contreras
  2012-01-30 22:17     ` Frank Terbeck
  2012-01-30 22:20     ` Vincent Lefevre
  0 siblings, 2 replies; 6+ messages in thread
From: Felipe Contreras @ 2012-01-30 21:46 UTC (permalink / raw)
  To: Frank Terbeck; +Cc: zsh-workers, Felipe Contreras

On Mon, Jan 30, 2012 at 10:43 PM, Frank Terbeck <ft@bewatermyfriend.org> wrote:
> Felipe Contreras wrote:
> [...]
>>       local t=$(echo foo --bar)
> [...]
>> But not in zsh, with sh emulation. Enabling KSH_TYPESET makes it work.
>>
>> Shouldn't it be enabled with sh emulation?
>>
>> BTW. What exactly is 'emulate sh' supposed to emulate? I would like to
>> run that shell to check for compatibility issues, and apparently it's
>> not bash.
>
> "emulate sh" is POSIX shell emulation (we did amend this mode in the
> past to work as much as possible as POSIX describes). Neither typeset
> nor local are part of POSIX (at least not SUSv3 - I don't know about
> v4).
>
> So, I don't think it should be enabled.

But it wouldn't hurt either, right? It would be nice to have some
'bash' emulation mode, but since there isn't any, why not enable this
harmless option?

> FWIW, dash and posh behave like zsh's sh-mode here. Ksh93 doesn't work
> at all, because it has no `local' (only typeset). Mksh, pdksh and bash
> work like KSH_TYPESET was set in zsh.

Hmm, I see, but there's no bash emulation mode =/

I guess it's time to compare the differences between ksh and sh
emulation to see which is closer.

-- 
Felipe Contreras


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

* Re: Bug with sh emulation; shouldn't KSH_TYPESET be set?
  2012-01-30 21:46   ` Felipe Contreras
@ 2012-01-30 22:17     ` Frank Terbeck
  2012-01-30 22:20     ` Vincent Lefevre
  1 sibling, 0 replies; 6+ messages in thread
From: Frank Terbeck @ 2012-01-30 22:17 UTC (permalink / raw)
  To: Felipe Contreras; +Cc: zsh-workers

Felipe Contreras wrote:
> Frank Terbeck <ft@bewatermyfriend.org> wrote:
[...]
>> So, I don't think it should be enabled.
>
> But it wouldn't hurt either, right? It would be nice to have some
> 'bash' emulation mode, but since there isn't any, why not enable this
> harmless option?

I'm unsure (personally, I wouldn't mind), as to whether the
argument-handling semantics of a random builtin can be changed with
POSIX in mind. Maybe someone with deeper understanding of the standard
can shed some light here.

I'd just do

    local foo="$(bar --baz)"

and be done with it. That should be portable over pretty much every
bourne-line shell that supports $(...) and `local',

>> FWIW, dash and posh behave like zsh's sh-mode here. Ksh93 doesn't work
>> at all, because it has no `local' (only typeset). Mksh, pdksh and bash
>> work like KSH_TYPESET was set in zsh.
>
> Hmm, I see, but there's no bash emulation mode =/
>
> I guess it's time to compare the differences between ksh and sh
> emulation to see which is closer.

Unsure, due to fairly limited knowledge of bash's extensions to POSIX.

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] 6+ messages in thread

* Re: Bug with sh emulation; shouldn't KSH_TYPESET be set?
  2012-01-30 21:46   ` Felipe Contreras
  2012-01-30 22:17     ` Frank Terbeck
@ 2012-01-30 22:20     ` Vincent Lefevre
  1 sibling, 0 replies; 6+ messages in thread
From: Vincent Lefevre @ 2012-01-30 22:20 UTC (permalink / raw)
  To: zsh-workers

On 2012-01-30 23:46:46 +0200, Felipe Contreras wrote:
> On Mon, Jan 30, 2012 at 10:43 PM, Frank Terbeck <ft@bewatermyfriend.org> wrote:
> > Felipe Contreras wrote:
> > [...]
> >>       local t=$(echo foo --bar)
> > [...]
> >> But not in zsh, with sh emulation. Enabling KSH_TYPESET makes it work.
> >>
> >> Shouldn't it be enabled with sh emulation?
> >>
> >> BTW. What exactly is 'emulate sh' supposed to emulate? I would like to
> >> run that shell to check for compatibility issues, and apparently it's
> >> not bash.
> >
> > "emulate sh" is POSIX shell emulation (we did amend this mode in the
> > past to work as much as possible as POSIX describes). Neither typeset
> > nor local are part of POSIX (at least not SUSv3 - I don't know about
> > v4).
> >
> > So, I don't think it should be enabled.
> 
> But it wouldn't hurt either, right?

Not sure. What if you have some executable named "local" in the path?

> It would be nice to have some 'bash' emulation mode, but since there
> isn't any, why not enable this harmless option?

Instead of changing options for sh emulation, why not add a 'bash'
emulation mode, even though it may not be perfect (it would be better
than sh anyway).

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


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

* Re: Bug with sh emulation; shouldn't KSH_TYPESET be set?
  2012-01-30 20:21 Bug with sh emulation; shouldn't KSH_TYPESET be set? Felipe Contreras
  2012-01-30 20:43 ` Frank Terbeck
@ 2012-01-31  9:43 ` Peter Stephenson
  1 sibling, 0 replies; 6+ messages in thread
From: Peter Stephenson @ 2012-01-31  9:43 UTC (permalink / raw)
  To: zsh-workers

On Mon, 30 Jan 2012 22:21:52 +0200
Felipe Contreras <felipe.contreras@gmail.com> wrote:
> This works on bash
> 
> ---
> _test ()
> {
> 	local t=$(echo foo --bar)
> }
> _test
> ---
> 
> But not in zsh, with sh emulation. Enabling KSH_TYPESET makes it work.
> 
> Shouldn't it be enabled with sh emulation?

Possibly --- I seem to remember there's a change request in POSIX to do
with this kind of stuff, but I'm not sure if it covered this case.

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog


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

end of thread, other threads:[~2012-01-31 10:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-30 20:21 Bug with sh emulation; shouldn't KSH_TYPESET be set? Felipe Contreras
2012-01-30 20:43 ` Frank Terbeck
2012-01-30 21:46   ` Felipe Contreras
2012-01-30 22:17     ` Frank Terbeck
2012-01-30 22:20     ` Vincent Lefevre
2012-01-31  9:43 ` Peter Stephenson

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).