Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #11582
| Path | csiph.com!xmission!news.glorb.com!usenet.stanford.edu!not-for-mail |
|---|---|
| From | bashbug@jonkmans.nl |
| Newsgroups | gnu.bash.bug |
| Subject | extglob syntax error in function definition |
| Date | Tue, 6 Oct 2015 14:27:32 +0200 (CEST) |
| Lines | 39 |
| Approved | bug-bash@gnu.org |
| Message-ID | <mailman.5.1444138815.916.bug-bash@gnu.org> (permalink) |
| NNTP-Posting-Host | lists.gnu.org |
| X-Trace | usenet.stanford.edu 1444138816 18180 208.118.235.17 (6 Oct 2015 13:40:16 GMT) |
| X-Complaints-To | action@cs.stanford.edu |
| To | bug-bash@gnu.org,bash@packages.debian.org |
| Envelope-to | bug-bash@gnu.org |
| X-Virus-Scanned | clamav-milter 0.98.7 at smtpgw.dds.nl |
| X-Virus-Status | Clean |
| X-detected-operating-system | by eggs.gnu.org: GNU/Linux 3.x [generic] |
| X-Received-From | 91.142.252.201 |
| X-Mailman-Approved-At | Tue, 06 Oct 2015 09:40:13 -0400 |
| X-BeenThere | bug-bash@gnu.org |
| X-Mailman-Version | 2.1.14 |
| Precedence | list |
| List-Id | Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org> |
| List-Unsubscribe | <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe> |
| List-Archive | <http://lists.gnu.org/archive/html/bug-bash> |
| List-Post | <mailto:bug-bash@gnu.org> |
| List-Help | <mailto:bug-bash-request@gnu.org?subject=help> |
| List-Subscribe | <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe> |
| Xref | csiph.com gnu.bash.bug:11582 |
Show key headers only | View raw
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I../. -I.././include -I.././lib -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wall
uname output: Linux ubak 3.13.0-30-generic #55-Ubuntu SMP Fri Jul 4 21:40:53 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu
Bash Version: 4.3
Patch Level: 30
Release Status: release
Description:
The shell gives a syntax error when defining a function that uses the extended pattern matching operators.
The man page does not mentin that extglob needs to be set at all. It does only say that it is needed for the !(...) construct.
But i reckon then that setting extglob is also of influence on the other operators: ?(..) , *(...) , +(...) and @(...) .
And indeed it is.
This works:
## assuming extglob is off by default
shopt -s extglob
isnum () { case "$1" in [1-9]*([0-9])) return 0 ;; *) return 1 ;; esac; }
shopt -u extglob
Drawback is that the global extglob setting is being manipulated in the current execution environment.
I would have expected that i could encapsulate the setting of extglob, by using a subshell-like function:
shopt -u extglob
isnum () ( shopt -s extglob; case "$1" in [1-9]*([0-9])) return 0 ;; *) return 1 ;; esac; )
But unfortunately this gives a syntax error.
It seems that the parser does not, at definition time, recognize the extended pattern matching construct.
Repeat-By:
shopt -u extglob
isnum () ( shopt -s extglob; case "$1" in [1-9]*([0-9])) return 0 ;; *) return 1 ;; esac; )
Back to gnu.bash.bug | Previous | Next | Find similar
extglob syntax error in function definition bashbug@jonkmans.nl - 2015-10-06 14:27 +0200
csiph-web