tech-userlevel archive

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

Re: sh -e changes broke pkgsrc



dholland-tech%NetBSD.org@localhost said:
>  > A subshell invocation is a command as any other.
> So dsl is wrong? (I just want to be as clear as possible, since this
> whole subject is extremely murky.) 

Yes, I think dsl is wrong in his response to bin/32282.
I think that the "simple command" arguments are misleading,
caused by poor wording in the POSIX spec.
A "(do && some || stuff)" subshell invocation does its
work on its own, and it can't be up to the outer shell
to look into its innards. Just the exit status counts.

This sounds a bit subjective, but it is consistent with
the behaviour of ksh, bash and old bourne shell implementations
like those of OSF/1 and Solaris. And it is generally
logical and sane.

Looking at the example in your earlier mail:
> set -e; false || (set +e; false)
The "set +e" shouldn't make a difference; the subshell invocation
gives a non-zero exit status in any case. So it should exit.

And dsl's example in bin/32282:
> sh -c 'set -e; (false && true); echo $?'
It should not execute the "echo": While the subshell is not
terminated due to the (inherited) "-e", it still gave a non-zero
exit status. So the outer shell is correct to terminate.

best regards
Matthias




-------------------------------------------------------------------
-------------------------------------------------------------------
Forschungszentrum Juelich GmbH
52425 Juelich

Sitz der Gesellschaft: Juelich
Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
Vorsitzende des Aufsichtsrats: MinDir'in Baerbel Brumme-Bothe
Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender),
Dr. Ulrich Krafft (stellv. Vorsitzender), Prof. Dr. Harald Bolt,
Dr. Sebastian M. Schmidt
-------------------------------------------------------------------
-------------------------------------------------------------------


Home | Main Index | Thread Index | Old Index