[Top][All Lists]

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

Re: [PATCH 6/6] use print or printf or cat as $ECHO

From: Eric Blake
Subject: Re: [PATCH 6/6] use print or printf or cat as $ECHO
Date: Mon, 10 Nov 2008 16:30:27 +0000 (UTC)
User-agent: Loom/3.14 (

Paolo Bonzini <bonzini <at>> writes:

> > At any rate, that means we should probably teach m4sh to try "print -r --"
> > as one of its options, prior to "printf %s\\n", during _AS_ECHO_PREPARE.
> Maybe, also because in that case we have "print -r -n --" too.  But:
> 1) these tests do cost a few subshells (which can be as expensive as a
> fork on bash, even if the executed command is a builtin).  In the
> attached patch I conditionalized it on ${TMOUT} so that it is not
> executed unless we're on ksh.

Sorry for cross-committing; I checked in a different patch before seeing
your mail, with a very similar idea.  Your filter based on TMOUT is different 
than my filter on {BASH,ZSH}_VERSION; I could go either way (I tested that 
pdksh also supplies both $TMOUT and print).

Things to consider: How likely is TMOUT to be exported in bash (causing a false 
positive), vs. BASH_VERSION to be exported in ksh (which causes way more 
problems than a spurious export of TMOUT)?  On the other hand, using a positive 
test (TMOUT being set) vs. a negative test (BASH_VERSION is not set) means that 
your version avoids 2 forks on ash or Solaris /bin/sh while mine does not.  
Should we document $TMOUT as a reliable way to detect ksh, the way we already 
use {BASH,ZSH}_VERSION as reliable witnesses of those two shells?

> 2) I'm not extremely fond of making the M4sh prolog even longer.
> To fix that you could rewrite
> _AS_RUN to use here documents, and change the remaining uses of AS_ECHO
> in error messages to cat.  Then you don't need at all anymore

Yes, avoiding $as_echo in the prolog would be nice, if the use of here-docs in 
_AS_RUN doesn't add an overall forking penalty.  Would you like to write that 

Eric Blake

reply via email to

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