RFR: 8243656: Shell built-in test in configure depends on help

Magnus Ihse Bursie magnus.ihse.bursie at oracle.com
Wed May 6 08:16:28 UTC 2020


On 2020-05-05 17:15, Severin Gehwolf wrote:
> Hi,
>
> Could I please get a review of this trivial change? Apparently using
> the help builtin for determining whether or not a builtin is available
> is not a good idea. A more portable way to do this is to use "command
> -v" or "type". Thanks to Michael Zucchi for contributing this fix.
>
> Bug: https://bugs.openjdk.java.net/browse/JDK-8243656
> webrev: http://cr.openjdk.java.net/~sgehwolf/webrevs/JDK-8243656/02/webrev/
Hi Severin,

I missed commenting on this before you pushed it, but does this really 
work?! Did you try it on your system?

I just tested the following:
$ command -V ps
ps is /bin/ps
$ command -V fg
fg is a shell builtin
$ command -v ps
/bin/ps
$ echo  $?
0
$ command -v fg
fg
$ echo  $?
0

That is, it does not seem like "command -v" is making any difference in 
return value between builtins and external commands!

Also, even if it should do, this is not documented and I don't think it 
should be relied on -- as evident, it does not work on my system.

In contrast, the (builtin) command "type" seems to work fine, and is 
documented to work:

$ type -t ps
file
$ type -t fg
builtin

I recommend that use $(type -t) = builtin instead.

/Magnus

>
> Testing: Local builds. jdk/submit.
>
> Thoughts?
>
> Thanks,
> Severin
>




More information about the build-dev mailing list