dash.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* "case" bug in dash
@ 2016-03-02 21:09 Adam Endrodi
  2016-03-02 21:18 ` Martijn Dekker
  0 siblings, 1 reply; 2+ messages in thread
From: Adam Endrodi @ 2016-03-02 21:09 UTC (permalink / raw)
  To: dash



Hi,


The following program prints "boo" incorrectly (I'm trying to match
non-numbers):

"""
#!/bin/dash

case "111" in
*[^0-9]*)
	echo boo;;
esac
"""

File expansion seems to be affected too:

/tmp/dash/src $ touch 111
/tmp/dash/src $ ./dash -c 'echo *[^0-9]*'
111 dash.1
/tmp/dash/src $ bash -c 'echo *[^0-9]*' 
alias.c alias.h alias.o arith_yacc.c arith_yacc.h arith_yacc.o arith_yylex.c arith_yylex.o bltin builtins.c builtins.def builtins.def.in builtins.h builtins.o cd.c cd.h cd.o dash dash.1 error.c error.h error.o eval.c eval.h eval.o exec.c exec.h exec.o expand.c expand.h expand.o funcs histedit.c histedit.o init.c init.h init.o input.c input.h input.o jobs.c jobs.h jobs.o machdep.h mail.c mail.h mail.o main.c main.h main.o Makefile Makefile.am Makefile.in memalloc.c memalloc.h memalloc.o miscbltin.c miscbltin.h miscbltin.o mkbuiltins mkinit mkinit.c mknodes mknodes.c mksignames mksignames.c mksyntax mksyntax.c mktokens myhistedit.h mystring.c mystring.h mystring.o nodes.c nodes.c.pat nodes.h nodes.o nodetypes options.c options.h options.o output.c output.h output.o parser.c parser.h parser.o
  printf.o redir.c redir.h redir.o shell.h show.c show.h show.o signames.c signames.o syntax.c syntax.h syntax.o system.c system.h system.o test.o times.o token.h token_vars.h TOUR trap.c trap.h trap.o var.c var.h var.o

Tried with 2e5842258bd5b252ffdaa630db09c9a19a9717ca (current git master)
both with --enable-glob and --disable-glob.

-- 
adam

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

* Re: "case" bug in dash
  2016-03-02 21:09 "case" bug in dash Adam Endrodi
@ 2016-03-02 21:18 ` Martijn Dekker
  0 siblings, 0 replies; 2+ messages in thread
From: Martijn Dekker @ 2016-03-02 21:18 UTC (permalink / raw)
  To: dash; +Cc: Adam Endrodi

Adam Endrodi schreef op 02-03-16 om 22:09:
> The following program prints "boo" incorrectly (I'm trying to match
> non-numbers):

That's correct. In shell glob pattern bracket expressions, the standard
negator is '!' and not '^'. Many shells support '^' as a synonym, but
that's an extension to the standard and not mandatory. Dash usually
doesn't support such extensions. But all shells support '!', so just
that instead and you're safe.

Reference:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_13
"If an open bracket introduces a bracket expression as in XBD RE 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, it shall introduce a pattern
bracket expression."

- M.


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

end of thread, other threads:[~2016-03-02 21:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-02 21:09 "case" bug in dash Adam Endrodi
2016-03-02 21:18 ` Martijn Dekker

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