[Top][All Lists]

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

Re: [Axiom-developer] Testing build-improvements

From: Gabriel Dos Reis
Subject: Re: [Axiom-developer] Testing build-improvements
Date: 22 Nov 2006 22:07:27 +0100

"Page, Bill" <address@hidden> writes:


| All of these commands executed properly on the
| server without changes to document - probably because of the default
| behaviour of bash. See the output attached below.
| But I noticed that you have many incorrectly quoted or unquoted
| parameters in the document script.

Please define more precisely what you mean by incorrectly quoted
and unquoted.  My guide on portable shell scripts usually is the 
notes in Autoconf.

  Shell Substitutions

  Contrary to a persistent urban legend, the Bourne shell does not
  systematically split variables and back-quoted expressions, in
  particular on the right-hand side of assignments and in the argument
  `case'.  For instance, the following code:

       case "$given_srcdir" in
       .)  top_srcdir="`echo "$dots" | sed 's,/$,,'`"
       *)  top_srcdir="$dots$given_srcdir" ;;

  is more readable when written as:

       case $given_srcdir in
       .)  top_srcdir=`echo "$dots" | sed 's,/$,,'`
       *)  top_srcdir=$dots$given_srcdir ;;

  and in fact it is even _more_ portable: in the first case of the first
  attempt, the computation of `top_srcdir' is not portable, since not all
  shells properly understand `"`..."..."...`"'.  Worse yet, not all
  shells understand `"`...\"...\"...`"' the same way.  There is just no
  portable way to use double-quoted strings inside double-quoted
  back-quoted expressions (pfew!).

| Perhaps that is what is causing
| your "quote micmac" with zsh. 

I'm not you're testing the right script.

| This sort of awkward and obscure
| construction is not necessary:
|            chunk=`echo -n $arg`
| I included a patch for document below. The corrected version of
| the document script generates the same output as but it is more
| robust on other systems with other shells and fully supports
| file names that include spaces (e.g. on Windows).
| Attachment:
| address@hidden scripts]$ ./document --tangle='TEST VIEW2D'
|  --output=test
| ~/
| + latex=latex
| + address@hidden@
| + tangle=/usr/local/bin/notangle
| + weave=/usr/local/bin/noweave
| + TEXINPUTS=.:/home/page/axiom.test/build/i686-pc-linux/share/texmf/tex:
| + export TEXINPUTS
| + BIBINPUTS=.:/home/page/axiom.test/build/i686-pc-linux/share/texmf/tex:
| + export BIBINPUTS
| + do_index=
| + do_latex=
| + do_tangle=
| + do_weave=
| + chunk=
| + file=
| + output=
| + :
| + do_tangle=yes
| ++ echo --tangle=TEST VIEW2D
| ++ awk -F= '{ print $2; }'

I believe you're testing a different document script from the one we
are discussing.   Therefore I'm not surprised at all that everything
is OK for you because I did ensure that it worked in the version
you're testing.
The one we're discussing does not have AWK anymore.


| Patch for document:
| Everywhere a variable is used in a parameter to an external
| command, it must be enclosed in "quotes". Note especially
| the command
|   $tangle "-R$chunk"
| The substitution must be made inside the quoted parameter.
| Also the notation
|   if test x$do_tangle = xyes; then
| is old and silly. This looks better and works the same.
|   if test "$do_tangle" = "yes"; then

However silly it appears to you (and me) I disagree with your removal
of x.  The above has been coded on purpose to be resilient to funky
shells and inputs.

`test' (strings)
     Avoid `test "STRING"', in particular if STRING might start with a
     dash, since `test' might interpret its argument as an option
     (e.g., `STRING = "-n"').

     Contrary to a common belief, `test -n STRING' and `test -z STRING'
     *are* portable.  Nevertheless many shells (such as Solaris 2.5,
     AIX 3.2, UNICOS, Digital Unix 4 etc.) have bizarre
     precedence and may be confused if STRING looks like an operator:

          $ test -n =
          test: argument expected

     If there are risks, use `test "xSTRING" = x' or `test "xSTRING" !=
     x' instead.

-- Gaby

reply via email to

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