[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug #33374] "local" as function name is questionable sh syntax
From: |
Jonathan Nieder |
Subject: |
[bug #33374] "local" as function name is questionable sh syntax |
Date: |
Mon, 23 May 2011 02:58:35 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.68 Safari/534.24 |
URL:
<http://savannah.gnu.org/bugs/?33374>
Summary: "local" as function name is questionable sh syntax
Project: texinfo - GNU documentation system
Submitted by: jrn
Submitted on: Mon 23 May 2011 02:58:33 AM GMT
Category: texi2dvi
Release: 2011-05-21
Priority: 3 - Low
Severity: 3 - Normal
Item Group: enhancement
Privacy: Public
Open/Closed: Open
Assigned to: None
Discussion Lock: Any
Status: None
_______________________________________________________
Details:
Hi,
As previously reported at <http://bugs.debian.org/619786>, texi2dvi errors out
when run using recent versions of dash from
git://git.kernel.org/pub/scm/utils/dash/dash.git as shell:
| $ texi2dvi
| /usr/bin/texi2dvi: 144: /usr/bin/texi2dvi: Syntax error: Bad function name
| $ sed -ne 144p /usr/bin/texi2dvi
| ) || local () {
| $ dash -c 'true || local () { echo hi; }; echo continuing'; echo $?
| dash: 1: Syntax error: Bad function name
| 2
The cause is use of "local" as a function name --- like typeset and export,
"local" is a special builtin in these versions of dash, and using it as a
function name is a syntax error[*].
ksh similarly errors out when it sees an attempt to define "export" or
"typeset" as a function, but it does not treat "local" as special, and perhaps
future versions of dash will follow that lead. So I am reporting this not to
say "this construct is invalid shell command language" but rather "this is at
the edge of portability and probably worth avoiding".
Anyway, it's simple to hide this construct from the parser for such shells by
wrapping the function definition in 'eval'. Shells that support "local" don't
have to parse that code and shells that do not support "local" are not going
to have a problem with it.
Thanks for reading, and hope that helps,
Jonathan
[*] http://austingroupbugs.net/view.php?id=383
_______________________________________________________
File Attachments:
-------------------------------------------------------
Date: Mon 23 May 2011 02:58:33 AM GMT Name: texi2dvi-local-fallback-syntax
Size: 1012B By: jrn
patch
<http://savannah.gnu.org/bugs/download.php?file_id=23438>
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?33374>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [bug #33374] "local" as function name is questionable sh syntax,
Jonathan Nieder <=