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.

   Julian

-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  Julian Gilbey, Dept of Maths, QMW, Univ. of London. [EMAIL PROTECTED]
        Debian GNU/Linux Developer,  see http://www.debian.org/~jdg
  Donate free food to the world's hungry: see http://www.thehungersite.com/

Reply via email to