Bruno Haible <[EMAIL PROTECTED]> writes: > Eric Blake wrote: >> > AC_CHECK_FUNCS([vasnprintf]) >> > if expr "$gl_cv_func_printf_sizes_c99" : ".*yes" > /dev/null \ >> > && expr "$gl_cv_func_printf_directive_a" : ".*yes" > /dev/null \ >> > && expr "$gl_cv_func_printf_directive_n" : ".*yes" > /dev/null \ >> > && expr "$gl_cv_func_printf_positions" : ".*yes" > /dev/null \ >> > && test $ac_cv_func_vasnprintf = yes; then >> > : # vasnprintf exists and is already POSIX compliant. >> >> This is rather expensive in the number of forks (ie. noticeably slows down >> ./configure on cygwin). Couldn't you rewrite it using shell builtins: >> >> case "$gl_cv_func_printf_sizes_c99:$gl_cv_func_printf_directive_a:..." in >> *no*) # vasnprintf needs help >> esac > > Sorry, no: Such a rewrite makes the code harder to understand, especially > the '&&' (vs. '||') part. Besides that, the second expr invocation already > fails on cygwin, therefore you wouldn't gain much. > > If you care about the execution speed of configure scripts, why don't you > ask > - either the cygwin people to provide a fast posix_spawn function, > - or the bash maintainers to make 'expr' and 'sed' shell built-ins, > like 'test' and 'printf' are?
I think it unlikely that either would happen; neither sounds all that practical. Another argument for using shell pattern matching is that expr is far less reliable in practice. It's not just that POSIX says the behavior of "expr A : B" is implementation-defined if A begins with "-", or is a special operand like ":" or "/". It's that expr is so buggy on many platforms. Sometimes we have to use expr, but it's better to avoid it when possible. How about something like this instead? Perhaps it's not quite as pretty, but it's equally easy to understand (at least for me). case $gl_cv_func_printf_sizes_c99 in *yes) case $gl_cv_func_printf_directive_a in *yes) case $gl_cv_func_printf_directive_n in *yes) case $gl_cv_func_printf_positions in *yes) case $gl_cv_func_snprintf_truncation_c99 in *yes) case $gl_cv_func_snprintf_retval_c99 in *yes) case $gl_cv_func_snprintf_directive_n in *yes) # snprintf exists and is already POSIX compliant. gl_cv_func_snprintf_posix=yes;; esac;; esac;; esac;; esac;; esac;; esac;; esac