Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #16254
| From | Robert Elz <kre@munnari.OZ.AU> |
|---|---|
| Newsgroups | gnu.bash.bug |
| Subject | Re: How functions are defined |
| Date | 2020-04-28 22:46 +0700 |
| Message-ID | <mailman.1487.1588088935.3066.bug-bash@gnu.org> (permalink) |
| References | <87pnbsfjss.fsf@hobgoblin.ariadne.com> <28227.1588088812@jinx.noi.kre.to> |
Date: Mon, 27 Apr 2020 22:03:47 -0400
From: worley@alum.mit.edu (Dale R. Worley)
Message-ID: <87pnbsfjss.fsf@hobgoblin.ariadne.com>
| While I was looking at the details of parsing function definitions, I
| tripped on something I should have noticed long ago. In the function
| definition
|
| function foo() {
| command
| }
I think this is your problem. The definition of a function is
really
name ( ) compound-command
and in the ksh/bash variant version
function name ( ) compound-command
There are no braces in the syntax (and I omitted redirections which are
not relevant here).
When looking for a "compound-command" we start out looking for the
first word of a command, and that's exactly where a reserved word
can be found.
Some shells actually permit
name ( ) command
instead where it is even clearer (but which gives rise to one small,
and mostly irrelevant, ambiguity - also not relevant here.)
Note that the text you quoted:
Reserved words are words that have a special meaning to the shell. The
following words are recognized as reserved when unquoted and either the
first word of a simple command ...
note that "first word" has nothing to do with lines, that the "name ()"
comes earlier doesn't mean that a command (or compound-command) doesn't
follow, and that thing starts with a "first word" (of itself).
kre
Back to gnu.bash.bug | Previous | Next | Find similar
Re: How functions are defined Robert Elz <kre@munnari.OZ.AU> - 2020-04-28 22:46 +0700
csiph-web