On Wed, 16 Nov 2022 19:59:35 GMT, Magnus Ihse Bursie <[email protected]> wrote:

>> bin/jib.sh line 137:
>> 
>>> 135:     FILEOUTPUT=`file ${installed_jib_script}.gz`
>>> 136:     # ${X:${#Y}} gives X without the first ${#Y} characters, and ${#Y} 
>>> is length of Y.
>>> 137:     FILEOUTPUT=${FILEOUTPUT:${#PREFIX}}
>> 
>> I think this is a bashism. While we do have /bin/bash in the shebang, this 
>> does not really matter since we have no executable bit on the script, so 
>> users will have to explicitly call it with a shell. So many users are likely 
>> to do `sh bin/jib.sh`, and then this will break.
>> 
>> My recommendation would be to use standard tools like cut or grep instead, 
>> something like:
>> 
>> file $installedscript.gz | grep "gzip compressed data" -q
>> if test $? -neq 0; then 
>> ...
>
> (Warning: untested code)
> 
> I also would like to clarify the use of bash. For configure script, and 
> scripts started by the makefiles, we rely on and enforce bash, so in those 
> cases bashisms are accepted (and almost encouraged, at least good ones). But 
> in "user facing" scripts like this, or the top level `configure` script, we 
> want to make minimal assumptions about the shell used, since the shebang path 
> means nothing in our case.

@magicus I've changed to something inspired by your comment and tested on 
linux, solaris and macos. Do you think the current version would be ok?

-------------

PR: https://git.openjdk.org/jdk/pull/11159

Reply via email to