Eric Sunshine <[EMAIL PROTECTED]> writes:
> (4) m4 strips away [ and ] characters as part of its normal processing, so
> you need to account for this in your 'sed' expression, as illustrated above
> with [[ and ]].
It might be better to use @<:@ and @:>@ for this (*note
(autoconf)Quadrigraphs::).
> For especially simple functions like yours, you can often easily define m4
> macros which get the job done just as well, without worrying about
> portability problems involved with shell functions. For instance, you can
> define an m4 macro ADD_TRAILING_SLASH which performs the same job as your
> shell function, and you can use it in the same way from configure.ac. For
> instance:
>
> # aclocal.m4
> AC_DEFUN([ADD_TRAILING_SLASH],
> [{ case $1 in
> */) echo "$1" ;;
> *) echo "$1/" ;;
> esac }
> ])
>
> # configure.ac
> AC_INIT(...)
> HAHA=`ADD_TRAILING_SLASH([$somevar])`
> AC_SUBST([HAHA])
> AC_OUTPUT
>
> Note that, in this case, the $1 is an argument of the m4 macro, and is
> expanded by m4. The $1 is not intended for the shell.
In which case you have to watch out for proper shell quoting, since the $1
in "case $1 in" may be replaced by a literal that includes meta
characters.
Andreas.
--
Andreas Schwab, SuSE Labs, [EMAIL PROTECTED]
SuSE Linux AG, Maxfeldstra�e 5, 90409 N�rnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."