On Sun, Jun 01, 2008 at 02:26:37AM +0000, Clint Adams wrote: > On Sat, May 31, 2008 at 06:21:35PM +0100, Stephane Chazelas wrote: > > $ local() { echo a; } > > $ local a > > $ "local" a > > $ > [...] > > Anyway, the above breaks POSIX conformance I think. POSIX only > > allows "select" and "function" as possible non-standard > > keywords. > > "local" was incorrectly marked as a special built-in, since > it was intended to behave similarly to export/readonly.
Hi Clint, then, posh has another problem with the other special builtins. As far, as I can tell, POSIX doesn't say that special builtin names can't be used as functions. But then ksh93 or ash don't allow it either... If posh doesn't allow it, it should report an error on the function declaration like ash or ksh93 IMO. > > If "local" were a keyword in posh, I would expect the first line > > above to give an error and the 3rd line to output "a\n". > > It's not a keyword, it's a builtin; what is your basis for the > quoting behavior? keywords are only recognised as keywords when not quoted as the quote removal is performed after the recognition of keywords. See also SUSv3: The following words may be recognized as reserved words on some implementations (when none of the characters are quoted), causing unspecified results: [[ ]] function select > > Note that given that "local" is not POSIX and can be written as > > a POSIX shell function with little effort if need be, it > > shouldn't be needed as a builtin, IMO. > > Hardcoding such a function definition into the shell seems less > robust than as a builtin. Sorry I wasn't clear. It is not what I meant. That was a critic of debian policy rather than posh's. I meant that encouraging people to write non-portable scripts by using the non-POSIX "local" was a bad idea given that there are POSIX alternatives to it. That is, script-writer can implement their own version of "local" (which will be more portable as the behavior of the built-in equivalent vary from shell to shell and can be used is other places than just functions) in the unlikely event they really need local scope in a sh shell script and still be portable. But the same goes for "echo -n". I don't see the point, given that there is a standard alternative, especially when you consider how unportable echo is. -- Stéphane -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]