On Wed, 29 Mar 2000, Julian Gilbey wrote:

> On Wed, Mar 29, 2000 at 12:05:34PM +0200, Denis Barbier wrote:
> > > the fmtutil script always return 0, which is confusing for script
> > > writers.
> > > 
> > > I would like to replace in all teTeX scripts traps like
> > >    trap 'cd /; ...some commands...; exit 0' 0 1 2 6 13 15
> > > by
> > >    trap 'rc=$?; cd /; ...some commands...; exit $rc' 0 1 2 6 13 15
> > 
> > On some systems (e.g. HP-UX 10.20/ksh), this does not work as expected.
> > Consider the file test.sh
> >    #!/bin/sh
> >    trap 'rc=$?; echo $rc; exit $rc' 0 1 2 15
> >    exit 1
> > 
> > And now, type
> >    sh test.sh || echo 1
> > 
> > On HP-UX 10.20 with ksh, it prints 0.
> > On Linux with bash, 1 is printed twice.
> > 
> > I do not know what is the right answer, but to let all OS behave like
> > the latter (which seems more logical) a workaround is to replace in
> > teTeX scripts all occurences of
> >    exit 1
> > by
> >    test 0 = 1 || exit 1
> 
> Or howabout:
>   rc=1; exit 1
> and then the trap command would just be:
>   trap ' ... some commands ... ; exit $rc' 0 1 2 15
> with an initial
>   rc=0
> command.

Have a look at texconfig around lines 196:
   chmod -t $1 || exit;
   chmod go-w $1 || exit;
and so on.  You have to write ``cmd || { rc=$?; exit; }''.
Now you will ask: and what about rc=1 by default?
Hmmm, yes it may be a good idea. In the original scripts, replace
   cmd; exit;
by
   cmd; rc=$?; exit
and
  exit 0
by
  rc=0; exit

I believe there are fewer changes than in my first proposal (2 against
12 in texconfig, do not know for others).

Denis

Reply via email to