Some shell tests contain '#!/bin/sh' but it is not the first line in the script, which is very suspicious. Often, it appears after the copyright block.
The following simple script detects anomalies. There are a couple of false positives, but most bear looking at:
-----8<-----
#!/bin/sh
files=$(find test -name \*.sh | xargs -n 1 grep --files-with-matches '#!/bin/sh')
#echo $files
for f in $files ; do
line1=$(head -n 1 $f)
if [ "$line1" != '#!/bin/sh' ]; then
echo "$f: $line1"
fi
done
----->8-----
The results of running this script on jdk/test are as follows:
$ sh play/badfirstline.sh
test/java/util/ResourceBundle/Bug6299235Test.sh: #
test/java/util/PluggableLocale/GenericTest.sh: #
test/java/util/PluggableLocale/CurrencyNameProviderTest.sh: #
test/java/util/PluggableLocale/BreakIteratorProviderTest.sh: #
test/java/util/PluggableLocale/LocaleNameProviderTest.sh: #
test/java/util/PluggableLocale/CollatorProviderTest.sh: #
test/java/util/PluggableLocale/NumberFormatProviderTest.sh: #
test/java/util/PluggableLocale/DecimalFormatSymbolsProviderTest.sh: #
test/java/util/PluggableLocale/DateFormatSymbolsProviderTest.sh: #
test/java/util/PluggableLocale/DateFormatProviderTest.sh: #
test/java/util/PluggableLocale/ClasspathTest.sh: #
test/java/util/PluggableLocale/CalendarDataProviderTest.sh: #
test/java/util/PluggableLocale/TimeZoneNameProviderTest.sh: #
test/java/util/PluggableLocale/ExecTest.sh: #
test/java/util/Locale/LocaleCategory.sh: #
test/java/util/Locale/LocaleProviders.sh: #
test/java/util/Locale/data/deflocale.sh: #
test/sun/rmi/rmic/newrmic/equivalence/batch.sh: #
test/sun/rmi/rmic/manifestClassPath/run.sh: #
test/sun/java2d/X11SurfaceData/SharedMemoryPixmapsTest/SharedMemoryPixmapsTest.sh: #
test/sun/management/jdp/JdpTest.sh: #!/bin/sh -x
test/start-Xvfb.sh: #!/bin/sh -f
test/tools/launcher/MultipleJRE.sh: # @test MultipleJRE.sh
The following simple script detects anomalies. There are a couple of false positives, but most bear looking at:
-----8<-----
#!/bin/sh
files=$(find test -name \*.sh | xargs -n 1 grep --files-with-matches '#!/bin/sh')
#echo $files
for f in $files ; do
line1=$(head -n 1 $f)
if [ "$line1" != '#!/bin/sh' ]; then
echo "$f: $line1"
fi
done
----->8-----
The results of running this script on jdk/test are as follows:
$ sh play/badfirstline.sh
test/java/util/ResourceBundle/Bug6299235Test.sh: #
test/java/util/PluggableLocale/GenericTest.sh: #
test/java/util/PluggableLocale/CurrencyNameProviderTest.sh: #
test/java/util/PluggableLocale/BreakIteratorProviderTest.sh: #
test/java/util/PluggableLocale/LocaleNameProviderTest.sh: #
test/java/util/PluggableLocale/CollatorProviderTest.sh: #
test/java/util/PluggableLocale/NumberFormatProviderTest.sh: #
test/java/util/PluggableLocale/DecimalFormatSymbolsProviderTest.sh: #
test/java/util/PluggableLocale/DateFormatSymbolsProviderTest.sh: #
test/java/util/PluggableLocale/DateFormatProviderTest.sh: #
test/java/util/PluggableLocale/ClasspathTest.sh: #
test/java/util/PluggableLocale/CalendarDataProviderTest.sh: #
test/java/util/PluggableLocale/TimeZoneNameProviderTest.sh: #
test/java/util/PluggableLocale/ExecTest.sh: #
test/java/util/Locale/LocaleCategory.sh: #
test/java/util/Locale/LocaleProviders.sh: #
test/java/util/Locale/data/deflocale.sh: #
test/sun/rmi/rmic/newrmic/equivalence/batch.sh: #
test/sun/rmi/rmic/manifestClassPath/run.sh: #
test/sun/java2d/X11SurfaceData/SharedMemoryPixmapsTest/SharedMemoryPixmapsTest.sh: #
test/sun/management/jdp/JdpTest.sh: #!/bin/sh -x
test/start-Xvfb.sh: #!/bin/sh -f
test/tools/launcher/MultipleJRE.sh: # @test MultipleJRE.sh