Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #11588
| Path | csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!usenet.stanford.edu!not-for-mail |
|---|---|
| From | Chet Ramey <chet.ramey@case.edu> |
| Newsgroups | gnu.bash.bug |
| Subject | Re: extglob syntax error in function definition |
| Date | Thu, 8 Oct 2015 10:35:53 -0400 |
| Organization | ITS, Case Western Reserve University |
| Lines | 38 |
| Approved | bug-bash@gnu.org |
| Message-ID | <mailman.20.1444315200.4386.bug-bash@gnu.org> (permalink) |
| References | <20151006122732.3006A264E1A@mail.jonkmans.nl> |
| Reply-To | chet.ramey@case.edu |
| NNTP-Posting-Host | lists.gnu.org |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 7bit |
| X-Trace | usenet.stanford.edu 1444315201 18120 208.118.235.17 (8 Oct 2015 14:40:01 GMT) |
| X-Complaints-To | action@cs.stanford.edu |
| Cc | chet.ramey@case.edu |
| To | bashbug@jonkmans.nl, bug-bash@gnu.org, bash@packages.debian.org |
| Envelope-to | bug-bash@gnu.org |
| User-Agent | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 |
| In-Reply-To | <20151006122732.3006A264E1A@mail.jonkmans.nl> |
| X-Junkmail-Whitelist | YES (by domain whitelist at mpv1.tis.cwru.edu) |
| X-detected-operating-system | by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] |
| X-Received-From | 129.22.105.36 |
| 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:11588 |
Show key headers only | View raw
On 10/6/15 8:27 AM, bashbug@jonkmans.nl wrote: > 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. This is fundamental to how the shell works. The shell always parses a complete command before executing any of it. A shell function definition is a compound command, so the shell parses the entire function definition at definition time rather than parsing it piece-by-piece on the fly at execution time. Since extglob changes parsing behavior to recognize the extended pattern matching operators -- which are otherwise syntax errors -- it needs to be enabled before parsing the function definition. > 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; ) It's not reasonable to expect the `shopt -s' to be executed as part of the function definition, without running the function at all. If you want to use the extended pattern matching syntax, you need to have extglob enabled before you try to parse any commands using it. That's just, as I said, fundamental. There is a compile-time option that enables extglob by default. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/
Back to gnu.bash.bug | Previous | Next | Find similar
Re: extglob syntax error in function definition Chet Ramey <chet.ramey@case.edu> - 2015-10-08 10:35 -0400
csiph-web