/[autoconf]/autoconf/doc/autoconf.texi
ViewVC logotype

Diff of /autoconf/doc/autoconf.texi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.608 by adl, Tue Apr 9 20:37:11 2002 UTC revision 1.609 by akim, Wed Apr 10 15:58:19 2002 UTC
# Line 7412  Any token matching @var{pattern} is allo Line 7412  Any token matching @var{pattern} is allo
7412  @c FIXME: Eventually will become a chapter, as it is not related to  @c FIXME: Eventually will become a chapter, as it is not related to
7413  @c programming in M4 per se.  @c programming in M4 per se.
7414    
7415    M4sh is aiming at producing portable Bourne shell scripts.  For the time
7416    being, it is not mature enough to be widely used.
7417    
7418  M4sh provides portable alternatives for some common shell constructs  M4sh provides portable alternatives for some common shell constructs
7419  that unfortunately are not portable in practice.  that unfortunately are not portable in practice.
7420    
# Line 8460  be equivalent to nothing.  But some shel Line 8463  be equivalent to nothing.  But some shel
8463  Unix 4.0 and 5.0, will then replace it with an empty argument.  To be  Unix 4.0 and 5.0, will then replace it with an empty argument.  To be
8464  portable, use @samp{$@{1+"$@@"@}}.  portable, use @samp{$@{1+"$@@"@}}.
8465    
8466    But that's not the end of the story.  Zsh (3.x and 4.x), when emulating
8467    the Bourne shell, does perform word splitting on @samp{$@{1+"$@@"@}}...
8468    
8469    @example
8470    zsh $ @kbd{emulate sh}
8471    zsh $ @kbd{for i in "$@"; do echo $i; done}
8472    Hello World
8473    !
8474    zsh $ @kbd{for i in $@{1+"$@@"@}; do echo $i; done}
8475    Hello
8476    World
8477    !
8478    @end example
8479    
8480    @noindent
8481    It is not clear whether this is a violation of the Bourne shell
8482    standard, nevertheless, in this regard Zsh is different from all the
8483    other shells.  Of course Zsh handles @samp{"$@@"} properly, but we can't
8484    use it portably...
8485    
8486    Fortunately, there is a workaround which relies on Zsh's ``global
8487    aliases'': let it convert @samp{$@{1+"$@@"@}} into @samp{"$@@"} by
8488    itself:
8489    
8490    @example
8491    test -n "$@{ZSH_VERSION+set@}" = set && alias -g '$@{1+"$@@"@}'='"$@@"'
8492    @end example
8493    
8494    
8495  @item $@{@var{var}:-@var{value}@}  @item $@{@var{var}:-@var{value}@}
8496  @c Info cannot handle `:' in index entries.  @c Info cannot handle `:' in index entries.
8497  @c @cindex $@{@var{var}:-@var{value}@}  @c @cindex $@{@var{var}:-@var{value}@}
# Line 8478  Be sure to quote: Line 8510  Be sure to quote:
8510  otherwise some shells, such as on Digital Unix V 5.0, will die because  otherwise some shells, such as on Digital Unix V 5.0, will die because
8511  of a ``bad substitution''.  of a ``bad substitution''.
8512    
8513    @sp 1
8514    
8515  Solaris' @command{/bin/sh} has a frightening bug in its interpretation  Solaris' @command{/bin/sh} has a frightening bug in its interpretation
8516  of this.  Imagine you need set a variable to a string containing  of this.  Imagine you need set a variable to a string containing
8517  @samp{@}}.  This @samp{@}} character confuses Solaris' @command{/bin/sh}  @samp{@}}.  This @samp{@}} character confuses Solaris' @command{/bin/sh}
# Line 9133  "@}; do Line 9167  "@}; do
9167  done  done
9168  @end example  @end example
9169    
9170    @noindent
9171    But keep in mind that Zsh, even in Bourne shell emulation mode, performs
9172    word splitting on @samp{$@{1+"$@@"@}}, see @ref{Shell Substitutions},
9173    item @samp{$@@}, for more.
9174    
9175    
9176  @item @command{if}  @item @command{if}
9177  @c ---------------  @c ---------------
9178  @prindex @command{if}  @prindex @command{if}

Legend:
Removed from v.1.608  
changed lines
  Added in v.1.609

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26