Follow-up Comment #8, bug #66479 (group groff): Hi Sven,
At 2024-11-30T05:11:58-0500, Sven Schober wrote:
> Sorry for comming back to you on this so late, I caught a cold and was
> unable to respond earlier.
I hope you've recovered!
> Unfortunately, your fix does not work for me, see the attached
> test-suite.log.
Sorry about that. The FSF France's compiler farm's macOS hosts seem
always to be unreachable for me--I always get timeouts when SSHing.
> I figure from the output, that `expr` is not able to perform the
> arithmetic operation, you are requesting:
>
> expr: not a decimal number: ' 46'
>
> I think, you wanted `expr`to coerce (right term?) the string into an
> integer by performing the addition on the first operand, right?
Correct. And leaving the argument unquoted is dangerous. (`wc` might
have been replaced by something that emits shell redirection operators,
or tries to change IFS, for example.)
> res=$(expr "$res" + 0) || exit 99
>
> I tried this also on an archlinux system I have available, where a
> coreutils `expr` is installed:
[...]
> export res=" 66"; expr "$res" + 0
> expr: non-integer argument
Hmm, yes, it didn't fail for me with GNU Coreutils because `wc` didn't
left-pad the integer in the first place.
At 2024-11-30T17:31:37-0500, Sven Schober wrote:
> Follow-up Comment #7, bug #66479 (group groff):
>
> Instead, I fount the following sh arithmetic expression to work:
>
>
> git diff
> diff --git a/contrib/hdtbl/examples/test-hdtbl.sh.in
> b/contrib/hdtbl/examples/test-hdtbl.sh.in
> index 3b5088db6..097b96640 100644
> --- a/contrib/hdtbl/examples/test-hdtbl.sh.in
> +++ b/contrib/hdtbl/examples/test-hdtbl.sh.in
> @@ -44,7 +44,7 @@ check_number_pages()
> res=$("$gs_program" -o /dev/null/ -sDEVICE=bbox "$1" 2>&1 \
> | grep HiResBoundingBox | wc -l)
> # macOS `wc` prefixes the line count with spaces. Get rid of them.
> - res=$(expr "$res" + 0) || exit 99
> + res=$((res + 0)) || exit 99
>
> if [ "$res" != $2 ]
> then
>
> Maybe that would be portable?
Likely more portable than any other kludge I can come up with.
It won't work with Solaris 10's /bin/sh...
$ echo $(( 1 + 2 ))
syntax error: `(' unexpected
...but our "PROBLEMS" file already warns that that shell is too
geriatric and demented to use.
---snip---
* Tests fail when I run "make check" on Solaris 10 or 11.
The test suite expects a POSIX-conforming shell and utilities. Solaris
10 does not offer these in the default $PATH. We try to use features
standardized no later than POSIX Issue 4 (1994). Unfortunately even
that is too recent for some implementations. Solaris 11 has a (mostly)
conforming shell. It may help to ensure that "/usr/xpg6/bin" and
"/usr/xpg4/bin" precede "/usr/bin" in the $PATH when building groff.
For Solaris 10, it is necessary to modify the shell-based test scripts
in place to use a conforming shell. Here is an example.
$ gsed -i -e '1s@#!/bin/sh@#!/usr/xpg4/bin/sh@' \
`find . -name '*.sh' | grep /tests/`
$ PATH=/usr/xpg4/bin:$PATH gmake check
...
---end snip---
So I will go with your solution, which is (a) idiomatic, and (b) known
to work!
Regards,
Branden
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?66479>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
signature.asc
Description: PGP signature
