Re: stumped on a simple autoconf/m4/sh problem

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

 



On Sun, Dec 1, 2024, at 10:03 PM, G. Branden Robinson wrote:
[...]
> So the "good tr" branch is being taken in the configure script, but
> not in vivo at a shell prompt.  I can't explain this.

I have no immediate explanation either.  On the Solaris 10 machine
from the GCC compile farm, I'm seeing your shell script fragment
behave as expected:

$ cat > test.sh <<\EOF
:
TR=no
for cmd in tr gtr
do
  if test \
    "`printf 'a\tb' | $cmd '[:cntrl:]' '[ *]' 2> /dev/null`" \
    = 'a b'
  then
    TR=$cmd
    break
  fi
done
echo $TR
EOF
$ bash test.sh
gtr
$ ksh test.sh
gtr
$ /usr/xpg4/bin/sh test.sh
gtr
$ /bin/sh test.sh
gtr

However, following up on Jacob Bachmeyer's observation that you have
/usr/xpg4/bin in your PATH:

$ PATH=/usr/xpg4/bin:$PATH /bin/sh test.sh
tr

which might be at least a partial explanation.

I am generally leery of doing something as complicated as what you
have inside a `test` expression.  I would suggest factoring that out
to a variable assignment.  I would also suggest you make the tr
invocation a little more robust by not throwing away the error
messages and detecting an unsuccessful exit code, and that you
take advantage of AC_PATH_PROGS_FEATURE_CHECK, which would, among
other things, set TR=/usr/xpg4/bin/tr instead of just TR=tr if it
picks that implementation.  And you probably need defensive x-es
in your `test` expressions.  Putting it all together, I would write
something like this:

AC_DEFUN([GROFF_FIND_POSIX_CONFORMING_TR], [
  AC_CACHE_CHECK([for a 'tr' that supports POSIX character classes],
    [ac_cv_path_TR],
    [AC_PATH_PROGS_FEATURE_CHECK([TR], [tr gtr],
      [[trout="`(printf 'a\tb\tc' | $ac_path_TR '[:cntrl:]' '[ *]' 2>&1) || printf fail`"
      if test x"$trout" = x"a b c"; then
        ac_cv_path_TR="$ac_path_TR"
        ac_path_TR_found=:
      fi]],
      [ac_cv_path_TR=no])])
   AC_SUBST([TR], [$ac_cv_path_TR])
   if test x"$TR" = xno; then
    AC_MSG_NOTICE([A 'tr' command that supports POSIX character \
classes was not found.

Some 'hdtbl' example documents will fail to generate, and some test
scripts exercised by 'make check' will also fail.])
  fi
])

Not tested at all, but give that a try and let us know what happens?

zw




[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux