This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [ANNOUNCEMENT] Updated: dash-0.5.9.1-1


On 2017-03-02 11:45, Eric Blake wrote:
> On 03/02/2017 11:28 AM, Brian Inglis wrote:
>> summary of checkbashisms -f run on 140 POSIX shell scripts as 
>> identified by file in my Cygwin 64 /bin/ with 784 packages (about
>> 20% of cygwin-pkg-maint, 8% of setup.ini) installed, 70 possible
>> issues (some from wrapped scripts because of -f):
> 
> Looking through some of the output, I already spot a few interesting
> things:
> 
>> possible bashism in /bin/autoconf-2.69 line 55 ($BASH_SOMETHING):
>> if test -z "$BASH_VERSION$ZSH_VERSION" \
>>     && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
> 
> Not a problem - the script is probing whether it needs to do
> something based on being bash or not, but is written with all shells
> in mind.
> 
>> error: /bin/autoconf-2.69: Unterminated quoted string found, EOF
>> reached. Wanted: <'>, opened in line 429
> 
> bug in checkbashisms; looks like it happens in several places in the
> output

Because of -f checks shell wrappers which it would otherwise just ignore 
- may not be helpful - but -px (POSIX + eXtra) may be more useful, as 
checkbashisms defaults to lintian checks where Debian Policy 10.4 
overrides POSIX.
Also running with -f on bash scripts and checking for exit 4 identifies 
candidates for changing shebang from bash to sh.

>> possible bashism in /bin/autopoint line 57 ($RANDOM):
>>     tmp=$TMPDIR/gt$$-$RANDOM
 
> Not a problem - the script is using $RANDOM for an additional level
> of safety, but works safely even when $RANDOM is the empty string (as
> on dash).

Those are where I suggested mktemp would be a better solution to provide 
a random string - most scripts using this open multiple temp files and 
are part of or used by autotools which may be run on MPs.

>> possible bashism in /bin/bzgrep line 66 (${parm/?/pat[/str]}):
>>     j=${i//\\/\\\\}
> 
> First real problem.  Except that 'grep j= /bin/bzgrep' has no hits on my
> system with bzip2-1.0.6-2 installed; what version was this problem in?

Cygwin patch release 1.0.6-3 installed 2017-02-24 but unchanged since 2007: 

$ ls -ghlo bzip2-1.0.6-3.src/bzip2-1.0.6/bzgrep
-rw-r--r--+ 1 1.7K Jan  2  2007 bzip2-1.0.6-3.src/bzip2-1.0.6/bzgrep

$ file /bin/bz{cmp,diff,less,more,*grep} # scripts from /etc/setup/bzip2.lst.gz
/bin/bzcmp:   symbolic link to bzdiff
/bin/bzdiff:  POSIX shell script, ASCII text executable
/bin/bzless:  symbolic link to bzmore
/bin/bzmore:  POSIX shell script, ASCII text executable
/bin/bzegrep: symbolic link to bzgrep
/bin/bzfgrep: symbolic link to bzgrep
/bin/bzgrep:  POSIX shell script, ASCII text executable
$ fgrep -C9 j= bzip2-1.0.6-3.src/bzip2-1.0.6/bzgrep
for i do
  if test -f "$i"; then :; else if test -f "$i.bz2"; then i="$i.bz2"; fi; fi
  if test $list -eq 1; then
    bzip2 -cdfq "$i" | $grep $opt "$pat" 2>&1 > /dev/null && echo $i
    r=$?
  elif test $# -eq 1 -o $silent -eq 1; then
    bzip2 -cdfq "$i" | $grep $opt "$pat"
    r=$?
  else
    j=${i//\\/\\\\}
    j=${j//|/\\|}
    j=${j//&/\\&}
    j=`printf "%s" "$j" | tr '\n' ' '`
    bzip2 -cdfq "$i" | $grep $opt "$pat" | sed "s|^|${j}:|"
    r=$?
  fi
  test "$r" -ne 0 && res="$r"
done
exit $res

Judgement call whether to change shebang or spawn sed or other?

Debian release is 1.0.6-7, bzgrep dated 2014, and bash expressions 
are gone, thanks to lintian and changes made to support more newer 
grep options.

>> possible bashism in /bin/messagebus-config line 26 (should be '.',
>> not 'source'):
>> source ${CSIH_SCRIPT}
> 
> Ah - now we get to an example file that is Cygwin-only (part of the 
> Cygwin port of dbus, but reading that file makes it obvious that it
> is not from upstream) - where changing /bin/sh will cause breakage
> that we can't rely on Debian to have caught first.

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]