It might be worth checking the return value of gzip too, though.
local asciidoctor_return
local gzip_return
asciidoctor --backend manpage --attribute=version="$BIT_VERSION" "$file"
--out-file=- | gzip --best > "$manfile"
read asciidoctor_return gzip_return _ <<< "${PIPESTATUS[@]}"
if (( asciidoctor_return != 0 || gzip_return !=0 )); then
exit 1
fi
The `read` command is doing something similar to this Python code
asciidoctor_return, gzip_return = PIPESTATUS[:2]
but in Bash it has to do something more equivalent to this:
asciidoctor_return, gzip_return, *_ = ' '.join(PIPESTATUS).split()
Derek Veit
On Tuesday, June 17th, 2025 at 8:16 AM, Derek via Bit-dev <[email protected]>
wrote:
>
>
> The call to asciidoctor is being fed through a pipe to gzip.
>
> https://github.com/bit-team/backintime/blob/780cbfd3089acd593de9d92907880fe7ac75befc/doc/manpages/build_manpages.sh#L23
>
> For a pipeline like this
> command1 | command2
> what you get is the return code from the command at the end, command2.
>
> gzip does not have an error, so the return code is 0, i.e. success.
>
> You can use PIPESTATUS to explicitly get around this:
>
> asciidoctor --backend manpage --attribute=version="$BIT_VERSION" "$file"
> --out-file=- | gzip --best > "$manfile"
>
> local return_code=${PIPESTATUS[0]}
> if (( return_code != 0 )); then
> exit 1
> fi
>
> PIPESTATUS is an array of the exit codes of the commands in the pipeline, so
> PIPESTATUS[0] has the return code from asciidoctor.
>
> You could write that condition as "(( return_code ))", but I think the
> explicit "!= 0" helps to make it much easier to understand correctly.
>
> Derek Veit
>
>
>
> On Monday, June 16th, 2025 at 11:44 AM, [email protected] [email protected]
> wrote:
>
> > Hello,
> > I do have a problem with the Makefile (in "common") and maybe some of you
> > have more
> > experience with it.
> >
> > In the latest dev version, the Makefile in "common" [1] does call a script
> > named "build_manpages.sh" [2]. That script does call "asciidoctor".
> >
> > If "asciidoctor" is not installed that script gives an error message (and
> > "exit 1").
> > I do see this error message when calling "./configure & make". But "make"
> > itself
> > does not recognize that error. The exit code of "make" does not indicate
> > that there
> > was an error.
> >
> > If there are other errors while "make" is running the last message usually
> > will
> > look like this:
> >
> > make: *** [Makefile:19: install] Error 2
> >
> > But when that error about the missing asciidoctor occur make does not give
> > that
> > error message at the end.
> >
> > I don't know what I am doing wrong. I think I miss some shell magic and Unix
> > basics here. ;)
> >
> > Regards,
> > Christian Buhtz
> >
> > [1] --
> > https://github.com/bit-team/backintime/blob/74e2030e017f9126eb5b75c643c12413c11b52dc/common/configure#L261-L267
> >
> > [2] --
> > https://github.com/bit-team/backintime/blob/dev/doc/manpages/build_manpages.sh
_______________________________________________
Bit-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/bit-dev.python.org
Member address: [email protected]