autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

more shell limitations


From: Eric Blake
Subject: more shell limitations
Date: Thu, 06 Jan 2005 07:32:00 -0700
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Is there any reason that
http://www.gnu.org/software/autoconf/manual/autoconf-2.59/index.html does
not link to an HTML version of the manual?  Sometimes I find it useful to
see the manual in the same browser where I clicked the link, rather than
firing up a separate process.

Also, in addition to the limitations of $(()) that I mentioned in
http://lists.gnu.org/archive/html/autoconf/2004-12/msg00180.html, I would
like to see the following limitations documented in the autoconf manual:

10 - the limitation on using functions should be updated to reflect the
reality that shell functions can be used by autoconf, after finding a
shell that supports them.  You should also document some of the function
limitations you have encountered, such as the behavior of $@ inside a
function.

10.9 - alias - not recommended for non-interactive scripts.  Although
Posix requires it, some shells (such as ash, which is cygwin's /bin/sh) do
not have it.  However, see the use of a global alias in section 10.5 to
make zsh Posix compliant.

(Note: Most of the time, functions can do everything an alias can.  There
are a few exceptions, however, such as

$ alias find='_find() { find "$@"; set +f; unset _find; }; set -f; _find'

from http://lists.debian.org/debian-user/2003/06/msg01038.html)

10.9 - export - although Posix requires it, some shells (such as Solaris 8
/bin/sh) do not support assignment during export, as in "export foo=bar".
~ Instead, make the assignment, then do the export:

$ foo=bar
$ export foo
$

(Question - is it portable to do 'foo=bar export foo', or does the
assignment need to be a separate line from the export?)

10.9 - function - bash supports 'function name { body }' as a synonym for
'name () compound-body', but other shells do not and Posix does not
require the alternate spelling.  Bash is compliant to Posix in the normal
syntax, in that compound-body can be { body }, (body), for, if, while,
case, or until; but in the alternate function syntax it requires {}.

$ function foo if : ; then echo hi ; fi
bash: syntax error near unexpected token `if'
$ foo () if : ; then echo hi ; fi
$ foo
hi
$

(Question - are there shells that support functions but do not support
compound-body besides {}?  Question - do the GNU coding conventions, or at
least autoconf, have a recommended style for function syntax?)

10.9 - shift - (Question - is 'shift n' portable, or should it always be
written 'shift; shift'... n times?)

10.9 - unalias - Although Posix requires it, some shells (such as ash,
which is cygwin's /bin/sh) do not have it.  However, it is sometimes
useful to unalias everything, to ensure that commands are not being
rewritten by unintended aliases.  The portable way to do this checks for
the existance of unalias first (notice the quoting, since some shells
allow unalias to be an alias!):

$ (\unalias -a) 2> /dev/null && \unalias -a
$

(Question - should autoconf be unaliasing everything as part of its shell
sanitization procedure?  Or at least quoting simple command words to
ensure that aliases aren't being expanded?)

- --
Life is short - so eat dessert first!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (Cygwin)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFB3Uvf84KuGfSFAYARAvu3AJ0d7bOLik2mTRRlZ4UTfwlO5QQGpwCgtvX/
gB0RlA+cDdsEtnwiJSRb50A=
=GiLB
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]