[PATCH] gen_build_files.sh: Remove bashisms

Cristian Ionescu-Idbohrn cristian.ionescu-idbohrn at axis.com
Mon May 17 21:54:11 UTC 2010


On Sun, 16 May 2010, Cristian Ionescu-Idbohrn wrote:

> On Sat, 15 May 2010, Denys Vlasenko wrote:
>
> > On Friday 14 May 2010 01:05, Peter Tyser wrote:
> > > -find -type d | while read; do
> > > -	d="$REPLY"
> > > -
> > > +find -type d | while read d; do
> >
> > I applied this part, and changed #!/bin/sh to bash.
> >
> > Thanks!
>
> Thank you.
>
> I had a look through and found:

under subdirectory scripts/, running 'file' on any of these scripts:

> ,----[ individual ]
> ,----[ mkdiff_obj ]
> ,----[ randomtest.loop ]
> ,----[ trylink ]

shows:

	POSIX shell script text executable

But that's only what the shebang line indicates.
They are 'Bourne-Again shell script text executable'.

The effort to make them portable is trivial.  Take 'trylink' for example.
This patch:

diff --git a/scripts/trylink b/scripts/trylink
index 8c88546..c6f307c 100755
--- a/scripts/trylink
+++ b/scripts/trylink
@@ -46,7 +46,11 @@ try() {
 }

 check_cc() {
-    local tempname="/tmp/temp.$$.$RANDOM"
+    local tempname=/tmp/temp.$$
+
+    tempname=$(mktemp $tempname.XXXXXXXXXX >/dev/null) ||
+	tempname=$tempname.$(date +%s.%N) >/dev/null
+
     # Can use "-o /dev/null", but older gcc tend to *unlink it* on failure! :(
     # "-xc": C language. "/dev/null" is an empty source file.
     if $CC $1 -shared -xc /dev/null -o "$tempname".o >/dev/null 2>&1; then
@@ -58,7 +62,11 @@ check_cc() {
 }

 check_libc_is_glibc() {
-    local tempname="/tmp/temp.$$.$RANDOM"
+    local tempname=/tmp/temp.$$
+
+    tempname=$(mktemp $tempname.XXXXXXXXXX >/dev/null) ||
+	tempname=$tempname.$(date +%s.%N) >/dev/null
+
     echo "\
 	#include <stdlib.h>
 	/* Apparently uclibc defines __GLIBC__ (compat trick?). Oh well. */

is what (I found) is needed to realy make it "POSIX shell script text
executable".


Cheers,

-- 
Cristian


More information about the busybox mailing list