* [PATCH] Remove bashisms from scripts/extract-ikconfig
@ 2007-06-09 19:22 Christian Kujau
2007-06-09 19:26 ` Julio M. Merino Vidal
0 siblings, 1 reply; 10+ messages in thread
From: Christian Kujau @ 2007-06-09 19:22 UTC (permalink / raw)
To: linux-kernel
Hi,
I noticed that scripts/extract-ikconfig is using /bin/sh in its shebang
but when /bin/sh is not a symlink to bash, it breaks with:
# scripts/extract-ikconfig /boot/vmlinux
scripts/extract-ikconfig: 11: function: not found
scripts/extract-ikconfig: 12: typeset: not found
The diff below seems to fix this.
Signed-off-by: Christian Kujau <lists@nerdbynature.de>
--- linux-2.6-dev/scripts/extract-ikconfig.orig 2007-06-01 22:53:49.000000000 +0200
+++ linux-2.6-dev/scripts/extract-ikconfig 2007-06-01 23:00:54.000000000 +0200
@@ -8,8 +8,8 @@ test -e $binoffset || cc -o $binoffset .
IKCFG_ST="0x49 0x4b 0x43 0x46 0x47 0x5f 0x53 0x54"
IKCFG_ED="0x49 0x4b 0x43 0x46 0x47 0x5f 0x45 0x44"
-function dump_config {
- typeset file="$1"
+dump_config() {
+ file="$1"
start=`$binoffset $file $IKCFG_ST 2>/dev/null`
[ "$?" != "0" ] && start="-1"
@@ -18,8 +18,8 @@ function dump_config {
fi
end=`$binoffset $file $IKCFG_ED 2>/dev/null`
- let start="$start + 8"
- let size="$end - $start"
+ start="`expr $start + 8`"
+ size="`expr $end - $start`"
dd if="$file" ibs=1 skip="$start" count="$size" 2>/dev/null | zcat
--
make bzImage, not war
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Remove bashisms from scripts/extract-ikconfig
2007-06-09 19:22 [PATCH] Remove bashisms from scripts/extract-ikconfig Christian Kujau
@ 2007-06-09 19:26 ` Julio M. Merino Vidal
2007-06-09 19:34 ` Christian Kujau
0 siblings, 1 reply; 10+ messages in thread
From: Julio M. Merino Vidal @ 2007-06-09 19:26 UTC (permalink / raw)
To: Christian Kujau; +Cc: linux-kernel
On 09/06/2007, at 21:22, Christian Kujau wrote:
> Hi,
>
> I noticed that scripts/extract-ikconfig is using /bin/sh in its
> shebang but when /bin/sh is not a symlink to bash, it breaks with:
> [...]
> @@ -18,8 +18,8 @@ function dump_config {
> fi
> end=`$binoffset $file $IKCFG_ED 2>/dev/null`
>
> - let start="$start + 8"
> - let size="$end - $start"
> + start="`expr $start + 8`"
> + size="`expr $end - $start`"
Wouldn't this be better expressed as:
start=$(($start + 8))
size=$(($end - $start))
to avoid invoking a subshell?
--
Julio M. Merino Vidal <jmerino@ac.upc.edu>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Remove bashisms from scripts/extract-ikconfig
2007-06-09 19:26 ` Julio M. Merino Vidal
@ 2007-06-09 19:34 ` Christian Kujau
2007-06-09 19:39 ` Julio M. Merino Vidal
2007-06-09 19:53 ` Willy Tarreau
0 siblings, 2 replies; 10+ messages in thread
From: Christian Kujau @ 2007-06-09 19:34 UTC (permalink / raw)
To: Julio M. Merino Vidal; +Cc: linux-kernel
On Sat, 9 Jun 2007, Julio M. Merino Vidal wrote:
> Wouldn't this be better expressed as:
>
> start=$(($start + 8))
> size=$(($end - $start))
>
> to avoid invoking a subshell?
This is certainly possible for lots for scripts, but was not the "scope"
of this patch. ` is not bash-specific and does not break anything.
--
make bzImage, not war
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Remove bashisms from scripts/extract-ikconfig
2007-06-09 19:34 ` Christian Kujau
@ 2007-06-09 19:39 ` Julio M. Merino Vidal
2007-06-09 19:53 ` Willy Tarreau
1 sibling, 0 replies; 10+ messages in thread
From: Julio M. Merino Vidal @ 2007-06-09 19:39 UTC (permalink / raw)
To: Christian Kujau; +Cc: linux-kernel
On 09/06/2007, at 21:34, Christian Kujau wrote:
> On Sat, 9 Jun 2007, Julio M. Merino Vidal wrote:
>> Wouldn't this be better expressed as:
>>
>> start=$(($start + 8))
>> size=$(($end - $start))
>>
>> to avoid invoking a subshell?
>
> This is certainly possible for lots for scripts, but was not the
> "scope" of this patch. ` is not bash-specific and does not break
> anything.
$((...)) is not bash-specific either.
--
Julio M. Merino Vidal <jmerino@ac.upc.edu>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Remove bashisms from scripts/extract-ikconfig
2007-06-09 19:34 ` Christian Kujau
2007-06-09 19:39 ` Julio M. Merino Vidal
@ 2007-06-09 19:53 ` Willy Tarreau
2007-06-09 20:14 ` Christian Kujau
1 sibling, 1 reply; 10+ messages in thread
From: Willy Tarreau @ 2007-06-09 19:53 UTC (permalink / raw)
To: Christian Kujau; +Cc: Julio M. Merino Vidal, linux-kernel
On Sat, Jun 09, 2007 at 09:34:36PM +0200, Christian Kujau wrote:
> On Sat, 9 Jun 2007, Julio M. Merino Vidal wrote:
> >Wouldn't this be better expressed as:
> >
> > start=$(($start + 8))
> > size=$(($end - $start))
> >
> >to avoid invoking a subshell?
>
> This is certainly possible for lots for scripts, but was not the "scope"
> of this patch. ` is not bash-specific and does not break anything.
That's wrong. It will now require "expr" to be present and working on
the machine, eventhough it's certainly needed for other parts of the
kernel. Also, the remaining function will be considerably slower than
what it initially was. If it's called very frequently, it can be a
problem.
I agree with Julio that if you want to fix the code for its bashism,
you should not change its behaviour and stay as much as possible close
to what it initially did.
Also, beware that the "typeset file=y" did another thing : declare "file"
as local to the function. With your change, any global variable called
"file" will have its content wiped after a call to this function. You
should ensure that it is not used anywhere else, or better, change its
name for something less common than "file".
Regards,
Willy
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Remove bashisms from scripts/extract-ikconfig
2007-06-09 19:53 ` Willy Tarreau
@ 2007-06-09 20:14 ` Christian Kujau
2007-11-14 23:44 ` Randy Dunlap
0 siblings, 1 reply; 10+ messages in thread
From: Christian Kujau @ 2007-06-09 20:14 UTC (permalink / raw)
To: Willy Tarreau; +Cc: Julio M. Merino Vidal, linux-kernel
On Sat, 9 Jun 2007, Willy Tarreau wrote:
> That's wrong. It will now require "expr" to be present and working on
> the machine, eventhough it's certainly needed for other parts of the
Oh, I was under the strange assumption that "expr" was a shell-builtin.
Well, it's not so I guess I'll just live with the bashism or try to
implement your proposals.
Thank you both for your comments,
Christian.
--
make bzImage, not war
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Remove bashisms from scripts/extract-ikconfig
2007-06-09 20:14 ` Christian Kujau
@ 2007-11-14 23:44 ` Randy Dunlap
0 siblings, 0 replies; 10+ messages in thread
From: Randy Dunlap @ 2007-11-14 23:44 UTC (permalink / raw)
To: Christian Kujau; +Cc: Willy Tarreau, Julio M. Merino Vidal, linux-kernel
Hi Christian,
Does the patch below satisfy your needs here?
Thanks,
~Randy
---
From: Christian Kujau <lists@nerdbynature.de>
Remove bashisms from scripts/extract-ikconfig (function and
typeset words).
Tested under dash v0.5.4 (latest/current).
Signed-off-by: Christian Kujau <lists@nerdbynature.de>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
---
scripts/extract-ikconfig | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
--- linux-2.6.24-rc2-git2.orig/scripts/extract-ikconfig
+++ linux-2.6.24-rc2-git2/scripts/extract-ikconfig
@@ -8,8 +8,9 @@ test -e $binoffset || cc -o $binoffset .
IKCFG_ST="0x49 0x4b 0x43 0x46 0x47 0x5f 0x53 0x54"
IKCFG_ED="0x49 0x4b 0x43 0x46 0x47 0x5f 0x45 0x44"
-function dump_config {
- typeset file="$1"
+
+dump_config() {
+ file="$1"
start=`$binoffset $file $IKCFG_ST 2>/dev/null`
[ "$?" != "0" ] && start="-1"
@@ -27,7 +28,6 @@ function dump_config {
exit 0
}
-
usage()
{
echo " usage: extract-ikconfig [b]zImage_filename"
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH] remove bashisms from scripts/extract-ikconfig
@ 2008-11-12 18:39 Werner Almesberger
2008-11-12 19:13 ` Randy Dunlap
2008-11-22 11:24 ` Sam Ravnborg
0 siblings, 2 replies; 10+ messages in thread
From: Werner Almesberger @ 2008-11-12 18:39 UTC (permalink / raw)
To: linux-kernel
unbashify-extract-ikconfig.patch
scripts/extract-ikconfig contains a lot of gratuituous bashisms,
which make it fail if /bin/sh isn't bash. This patch replaces them
with regular Bourne shell constructs.
Signed-off-by: Werner Almesberger <werner@openmoko.org>
---
diff --git a/scripts/extract-ikconfig b/scripts/extract-ikconfig
index 8187e6f..72997c3 100755
--- a/scripts/extract-ikconfig
+++ b/scripts/extract-ikconfig
@@ -8,8 +8,8 @@ test -e $binoffset || cc -o $binoffset ./scripts/binoffset.c || exit 1
IKCFG_ST="0x49 0x4b 0x43 0x46 0x47 0x5f 0x53 0x54"
IKCFG_ED="0x49 0x4b 0x43 0x46 0x47 0x5f 0x45 0x44"
-function dump_config {
- typeset file="$1"
+dump_config() {
+ file="$1"
start=`$binoffset $file $IKCFG_ST 2>/dev/null`
[ "$?" != "0" ] && start="-1"
@@ -18,8 +18,8 @@ function dump_config {
fi
end=`$binoffset $file $IKCFG_ED 2>/dev/null`
- let start="$start + 8"
- let size="$end - $start"
+ start=`expr $start + 8`
+ size=`expr $end - $start`
dd if="$file" ibs=1 skip="$start" count="$size" 2>/dev/null | zcat
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] remove bashisms from scripts/extract-ikconfig
2008-11-12 18:39 [PATCH] remove " Werner Almesberger
@ 2008-11-12 19:13 ` Randy Dunlap
2008-11-22 11:24 ` Sam Ravnborg
1 sibling, 0 replies; 10+ messages in thread
From: Randy Dunlap @ 2008-11-12 19:13 UTC (permalink / raw)
To: Werner Almesberger; +Cc: linux-kernel, Andrew Morton
Werner Almesberger wrote:
> unbashify-extract-ikconfig.patch
>
> scripts/extract-ikconfig contains a lot of gratuituous bashisms,
> which make it fail if /bin/sh isn't bash. This patch replaces them
> with regular Bourne shell constructs.
>
> Signed-off-by: Werner Almesberger <werner@openmoko.org>
Acked-by: Randy Dunlap <randy.dunlap@oracle.com> # as file author
> ---
>
> diff --git a/scripts/extract-ikconfig b/scripts/extract-ikconfig
> index 8187e6f..72997c3 100755
> --- a/scripts/extract-ikconfig
> +++ b/scripts/extract-ikconfig
> @@ -8,8 +8,8 @@ test -e $binoffset || cc -o $binoffset ./scripts/binoffset.c || exit 1
>
> IKCFG_ST="0x49 0x4b 0x43 0x46 0x47 0x5f 0x53 0x54"
> IKCFG_ED="0x49 0x4b 0x43 0x46 0x47 0x5f 0x45 0x44"
> -function dump_config {
> - typeset file="$1"
> +dump_config() {
> + file="$1"
>
> start=`$binoffset $file $IKCFG_ST 2>/dev/null`
> [ "$?" != "0" ] && start="-1"
> @@ -18,8 +18,8 @@ function dump_config {
> fi
> end=`$binoffset $file $IKCFG_ED 2>/dev/null`
>
> - let start="$start + 8"
> - let size="$end - $start"
> + start=`expr $start + 8`
> + size=`expr $end - $start`
>
> dd if="$file" ibs=1 skip="$start" count="$size" 2>/dev/null | zcat
>
> --
--
~Randy
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] remove bashisms from scripts/extract-ikconfig
2008-11-12 18:39 [PATCH] remove " Werner Almesberger
2008-11-12 19:13 ` Randy Dunlap
@ 2008-11-22 11:24 ` Sam Ravnborg
1 sibling, 0 replies; 10+ messages in thread
From: Sam Ravnborg @ 2008-11-22 11:24 UTC (permalink / raw)
To: Werner Almesberger; +Cc: linux-kernel
On Wed, Nov 12, 2008 at 04:39:35PM -0200, Werner Almesberger wrote:
> unbashify-extract-ikconfig.patch
>
> scripts/extract-ikconfig contains a lot of gratuituous bashisms,
> which make it fail if /bin/sh isn't bash. This patch replaces them
> with regular Bourne shell constructs.
>
> Signed-off-by: Werner Almesberger <werner@openmoko.org>
Applied to kbuild-next with Randy's ack.
Sam
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2008-11-22 11:25 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-09 19:22 [PATCH] Remove bashisms from scripts/extract-ikconfig Christian Kujau
2007-06-09 19:26 ` Julio M. Merino Vidal
2007-06-09 19:34 ` Christian Kujau
2007-06-09 19:39 ` Julio M. Merino Vidal
2007-06-09 19:53 ` Willy Tarreau
2007-06-09 20:14 ` Christian Kujau
2007-11-14 23:44 ` Randy Dunlap
-- strict thread matches above, loose matches on Subject: below --
2008-11-12 18:39 [PATCH] remove " Werner Almesberger
2008-11-12 19:13 ` Randy Dunlap
2008-11-22 11:24 ` Sam Ravnborg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox