* patch to fix bashism
@ 2005-04-08 21:12 Han Boetes
2005-04-09 20:18 ` David Weinehall
0 siblings, 1 reply; 2+ messages in thread
From: Han Boetes @ 2005-04-08 21:12 UTC (permalink / raw)
To: linux-kernel; +Cc: Martin Schlemmer
Hi,
This patch fixes a three bashisms in
scripts/gen_initramfs_list.sh;
I'm not sure of the intention of the second change (local
name=...). So it's very well possible that:
+ local name="${location%/$srcdir}"
is more appropriate.
--- scripts/gen_initramfs_list.sh.orig 2005-03-27 14:53:15.628883408 +0200
+++ scripts/gen_initramfs_list.sh 2005-03-27 15:12:20.093898280 +0200
@@ -1,4 +1,7 @@
-#!/bin/bash
+#!/bin/sh
+
+# script is sourced, the shebang is ignored.
+
# Copyright (C) Martin Schlemmer <azarah@nosferatu.za.org>
# Released under the terms of the GNU GPL
#
@@ -56,9 +59,9 @@
parse() {
local location="$1"
- local name="${location/${srcdir}//}"
+ local name="${location#$srcdir/}"
# change '//' into '/'
- name="${name//\/\///}"
+ name=`echo $name|sed -e 's|//|/|g'`
local mode="$2"
local uid="$3"
local gid="$4"
@@ -68,8 +71,8 @@
[ "$gid" -eq "$root_gid" ] && gid=0
local str="${mode} ${uid} ${gid}"
- [ "${ftype}" == "invalid" ] && return 0
- [ "${location}" == "${srcdir}" ] && return 0
+ [ "${ftype}" = "invalid" ] && return 0
+ [ "${location}" = "${srcdir}" ] && return 0
case "${ftype}" in
"file")
# Han
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: patch to fix bashism
2005-04-08 21:12 patch to fix bashism Han Boetes
@ 2005-04-09 20:18 ` David Weinehall
0 siblings, 0 replies; 2+ messages in thread
From: David Weinehall @ 2005-04-09 20:18 UTC (permalink / raw)
To: linux-kernel, Martin Schlemmer
On Fri, Apr 08, 2005 at 11:11:38PM +0159, Han Boetes wrote:
> Hi,
>
> This patch fixes a three bashisms in
> scripts/gen_initramfs_list.sh;
>
> I'm not sure of the intention of the second change (local
> name=...). So it's very well possible that:
>
> + local name="${location%/$srcdir}"
>
> is more appropriate.
This patch is not going to work; local is a bash:ism too, hence this
will fail when /bin/sh is a more strict POSIX-shell. However,
it is quite likely that the use of local is merely due to the
(totally correct) instinct of always limiting the scope of variables.
Most scripts that I've POSIX-fixed so far could just have the local
removed with no bad effects.
> --- scripts/gen_initramfs_list.sh.orig 2005-03-27 14:53:15.628883408 +0200
> +++ scripts/gen_initramfs_list.sh 2005-03-27 15:12:20.093898280 +0200
> @@ -1,4 +1,7 @@
> -#!/bin/bash
> +#!/bin/sh
> +
> +# script is sourced, the shebang is ignored.
> +
> # Copyright (C) Martin Schlemmer <azarah@nosferatu.za.org>
> # Released under the terms of the GNU GPL
> #
> @@ -56,9 +59,9 @@
>
> parse() {
> local location="$1"
> - local name="${location/${srcdir}//}"
> + local name="${location#$srcdir/}"
> # change '//' into '/'
> - name="${name//\/\///}"
> + name=`echo $name|sed -e 's|//|/|g'`
Using $(...) instead of `...` helps readability quite a lot for
things like this...
[snip]
Regards: David Weinehall
--
/) David Weinehall <tao@acc.umu.se> /) Northern lights wander (\
// Maintainer of the v2.0 kernel // Dance across the winter sky //
\) http://www.acc.umu.se/~tao/ (/ Full colour fire (/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-04-09 20:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-08 21:12 patch to fix bashism Han Boetes
2005-04-09 20:18 ` David Weinehall
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®