zsh-workers
 help / color / mirror / code / Atom feed
* Incompatibility when Zsh invoked as 'sh'
@ 2002-02-03 23:13 DervishD
  2002-02-04  2:51 ` Dan Nelson
  0 siblings, 1 reply; 6+ messages in thread
From: DervishD @ 2002-02-03 23:13 UTC (permalink / raw)
  To: Zsh

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 891 bytes --]

    Hello zshworkers :))

    I don't know if this is an incompatibility or just bad scripting
;)), but when running the GNU libc (version 2.2.4) 'catchsegv'
script, Zsh complains. Zsh is being invoked as 'sh' here, I'm sure of
it, at least.

    The problem is a 'case' like this (abbreviated):

    case "$1" in
        [*)  ....
            ;;
        *)   ....
            ;;
    esac

    Well, the error is the '[*' pattern, which zsh says is a 'bat
pattern'. Bash treats it as the regex 'match an opening bracket and
anything after it', but zsh doesn't.

    Assuming that zsh is running in 'sh' compatibility mode (because
it is invoked 'sh'), it shouldn't treat '[' as an special character
(the problem is that the bracket must be quoted), should it?

    If Zsh is behaving well, the GNU libc people should be told about
quoting the offending char.

    Thanks a lot :)

    Raúl


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

* Re: Incompatibility when Zsh invoked as 'sh'
  2002-02-03 23:13 Incompatibility when Zsh invoked as 'sh' DervishD
@ 2002-02-04  2:51 ` Dan Nelson
  2002-02-04  3:46   ` Bart Schaefer
  0 siblings, 1 reply; 6+ messages in thread
From: Dan Nelson @ 2002-02-04  2:51 UTC (permalink / raw)
  To: DervishD; +Cc: Zsh

In the last episode (Feb 04), DervishD said:
>     The problem is a 'case' like this (abbreviated):
> 
>     case "$1" in
>         [*)  ....
>             ;;
>         *)   ....
>             ;;
>     esac
> 
>     Well, the error is the '[*' pattern, which zsh says is a 'bat
> pattern'. Bash treats it as the regex 'match an opening bracket and
> anything after it', but zsh doesn't.

couple datapoints:

ash does not complain; args starting with a bracket match the 1st case.

pdksh-5.2.14 run as sh does not complain, but only the literal argument
  [* matches.

The ash manpage, at least, explicitly allows this case:

     A left bracket ([) introduces a character class.  The end of the
     character class is indicated by a ``]''; if the ``]'' is missing
     then the ``['' matches a ``['' rather than introducing a character
     class.

I don't have a link to the new Single Unix spec at the moment; what's
it say?

-- 
	Dan Nelson
	dnelson@allantgroup.com


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

* Re: Incompatibility when Zsh invoked as 'sh'
  2002-02-04  2:51 ` Dan Nelson
@ 2002-02-04  3:46   ` Bart Schaefer
  2002-02-04 10:14     ` Peter Stephenson
  0 siblings, 1 reply; 6+ messages in thread
From: Bart Schaefer @ 2002-02-04  3:46 UTC (permalink / raw)
  To: DervishD, Zsh, Dan Nelson

On Feb 4, 12:13am, DervishD wrote:
}
}     Well, the error is the '[*' pattern, which zsh says is a 'bat
} pattern'. Bash treats it as the regex 'match an opening bracket and
} anything after it', but zsh doesn't.

On Feb 3,  8:51pm, Dan Nelson wrote:
}
} ash does not complain; args starting with a bracket match the 1st case.
} 
} pdksh-5.2.14 run as sh does not complain, but only the literal argument
}   [* matches.
} 
} I don't have a link to the new Single Unix spec at the moment; what's
} it say?

Anyone who registers their email address can now get the latest Single
Unix spec on line; start at http://www.unix-systems.org/version3/

The spec says:

  When unquoted and outside a bracket expression, the following three
  characters shall have special meaning in the specification of patterns:

  ?   A question-mark is a pattern that shall match any character.
  *   An asterisk is a pattern that shall match multiple characters, as
      described in Patterns Matching Multiple Characters.
  [   The open bracket shall introduce a pattern bracket expression.

It goes on:

  Section 9.3.5, RE Bracket Expression shall also apply to the pattern
  bracket expression, except that the exclamation mark character ( '!' )
  shall replace the circumflex character ( '^' ) in its role in a "non-
  matching list" in the regular expression notation. A bracket expression
  starting with an unquoted circumflex character produces unspecified
  results.

Nothing in section 9.3.5 allows for an unmatched left-bracket to match a
literal bracket.  The description of the "case" construct doesn't make
any exception to this, either.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


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

* Re: Incompatibility when Zsh invoked as 'sh'
  2002-02-04  3:46   ` Bart Schaefer
@ 2002-02-04 10:14     ` Peter Stephenson
  0 siblings, 0 replies; 6+ messages in thread
From: Peter Stephenson @ 2002-02-04 10:14 UTC (permalink / raw)
  To: Zsh hackers list

"Bart Schaefer" wrote:
> On Feb 4, 12:13am, DervishD wrote:
> }
> }     Well, the error is the '[*' pattern, which zsh says is a 'bat
> } pattern'. Bash treats it as the regex 'match an opening bracket and
> } anything after it', but zsh doesn't.
> 
> Nothing in section 9.3.5 allows for an unmatched left-bracket to match a
> literal bracket.  The description of the "case" construct doesn't make
> any exception to this, either.

I suppose it's those shells' way of getting round the problem of treating a
single `[' as the start of a test without needing it quoted.  Zsh makes an
exception in that single case only; maybe the others make an exception for
any word starting with `['.  I certainly can't see any good reason for
changing.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 392070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************


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

* Re: Incompatibility when Zsh invoked as 'sh'
@ 2002-02-04 10:07 DervishD
  0 siblings, 0 replies; 6+ messages in thread
From: DervishD @ 2002-02-04 10:07 UTC (permalink / raw)
  To: dnelson, raul, schaefer, zsh-workers

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 330 bytes --]

    Hello Bart :)

>Nothing in section 9.3.5 allows for an unmatched left-bracket to match a
>literal bracket.  The description of the "case" construct doesn't make
>any exception to this, either.

    That is, the bracket must be closed or quoted. I'll send a bug
report to the GNU libc people.

    Thanks for all :)

    Raúl


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

* Re: Incompatibility when Zsh invoked as 'sh'
@ 2002-02-04 10:06 DervishD
  0 siblings, 0 replies; 6+ messages in thread
From: DervishD @ 2002-02-04 10:06 UTC (permalink / raw)
  To: dnelson, raul; +Cc: zsh-workers

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 231 bytes --]

    Hello Dan :)

>I don't have a link to the new Single Unix spec at the moment; what's
>it say?

    That the '[' introduces a pattern bracket expression. Details are
in the XBD specification (haven't look at it yet).

    Raúl


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

end of thread, other threads:[~2002-02-04 10:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-03 23:13 Incompatibility when Zsh invoked as 'sh' DervishD
2002-02-04  2:51 ` Dan Nelson
2002-02-04  3:46   ` Bart Schaefer
2002-02-04 10:14     ` Peter Stephenson
2002-02-04 10:06 DervishD
2002-02-04 10:07 DervishD

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