Re: [PATCH v3 1/4] Do not ignore errors from tar

Alyssa Ross
2025-09-30T13:00:01Z

[-- Attachment #1: Type: text/plain, Size: 1878 bytes --]

Alyssa Ross <hi@alyssa.is> writes:

> Demi Marie Obenour <demiobenour@gmail.com> writes:
>
>> On 9/17/25 07:48, Alyssa Ross wrote:
>>> Demi Marie Obenour <demiobenour@gmail.com> writes:
>>>
>>>> These would be ignored due to a missing -o pipefail in the shell script.
>>>> As a result, listing nonexistent s6-rc-compile inputs would cause a
>>>> broken image to be successfully built.
>>>>
>>>> Reported-by: Alyssa Ross <hi@alyssa.is>
>>>> Link: https://spectrum-os.org/lists/archives/spectrum-devel/87segu879h.fsf@alyssa.is
>>>> Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
>>>> ---
>>>> host/rootfs/Makefile | 4 ++--
>>>> img/app/Makefile | 4 ++--
>>>> vm/sys/net/Makefile | 4 ++--
>>>> 3 files changed, 6 insertions(+), 6 deletions(-)
>>>>
>>>> diff --git a/host/rootfs/Makefile b/host/rootfs/Makefile
>>>> index e96458dba06ae31129b115b2b649962f8d88187a..2288ae4d22ca817ba9fe8ebfc42326fe38b27c27 100644
>>>> --- a/host/rootfs/Makefile
>>>> +++ b/host/rootfs/Makefile
>>>> @@ -169,8 +169,8 @@ build/etc/s6-rc: $(S6_RC_FILES)
>>>> mkdir -p $$(dirname $@)
>>>> rm -rf $@
>>>>
>>>> - dir=$$(mktemp -d) && \
>>>> - tar -c $(S6_RC_FILES) | tar -C $$dir -x --strip-components 2 && \
>>>> + set -uo pipefail; dir=$$(mktemp -d) || exit; \
>>>> + { tar -c $(S6_RC_FILES) | tar -C $$dir -x --strip-components 2; } && \
>>>> s6-rc-compile $@ $$dir; \
>>>> exit=$$?; rm -r $$dir; exit $$exit
>>>>
>>>
>>> What do the additional { } do?
>> Cause s6-rc-compile to be skipped if either tar command fails.
>
> Ah, like a subshell without creating a subshell! I haven't seen that
> before. Probably there are lots of places where I'm needlessly using
> subshells, then.

Fixed the ones I could find in
https://spectrum-os.org/git/spectrum/commit/?id=7ce3a09b48a53ec4c23edf713b9c3b1ee2de3339 :)

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 227 bytes --]