[U-Boot] v2015.01-rc4 REGRESSION: "scripts: fix binutils-version.sh" breaks things for non Linaro toolchains
Bill Pringlemeir
bpringlemeir at nbsps.com
Tue Jan 6 22:32:26 CET 2015
On 6 Jan 2015, trini at ti.com wrote:
> On Tue, Jan 06, 2015 at 11:27:43AM +0100, Hans de Goede wrote:
>> Hi all,
>>
>> ping ? current master still has this regression, it is not fatal,
>> but it is not
>> pretty either.
>
> Did you see my earlier reply? It's OK with vanilla toolchains (see
> ELDK) and Linaro ones, but breaking on how Fedora mangles the version
> string. I'm _not_ saying it's a Fedora problem, but can you poke at
> this a bit? If not, I'll play with echo and see if I can do it.
I did a shell check on this script,
shellcheck -f gcc binutils-version.sh
binutils-version.sh:13:9: warning: Don't use variables in the printf format string. Use printf "..%s.." "$foo". [SC2059]
binutils-version.sh:19:14: note: Double quote to prevent globbing and word splitting. [SC2086]
binutils-version.sh:20:14: note: Double quote to prevent globbing and word splitting. [SC2086]
binutils-version.sh:22:22: note: Double quote to prevent globbing and word splitting. [SC2086]
binutils-version.sh:22:29: note: Double quote to prevent globbing and word splitting. [SC2086]
diff --git a/scripts/binutils-version.sh b/scripts/binutils-version.sh
index 0bc26cf..955267d 100755
--- a/scripts/binutils-version.sh
+++ b/scripts/binutils-version.sh
@@ -5,7 +5,6 @@
# Prints the binutils version of `gas-command' in a canonical 4-digit form
# such as `0222' for binutils 2.22
#
-
gas="$*"
if [ ${#gas} -eq 0 ]; then
@@ -14,9 +13,9 @@ if [ ${#gas} -eq 0 ]; then
exit 1
fi
-version_string=$($gas --version | head -1 | sed -e 's/.*) *\([0-9.]*\).*/\1/' )
+version_string=$($gas --version | head -1 | sed -e 's/.*) *\([0-9\.]*\).*/\1/' )
-MAJOR=$(echo $version_string | cut -d . -f 1)
-MINOR=$(echo $version_string | cut -d . -f 2)
+MAJOR=$(echo "$version_string" | cut -d . -f 1)
+MINOR=$(echo "$version_string" | cut -d . -f 2)
-printf "%02d%02d\\n" $MAJOR $MINOR
+printf "%02d%02d\\n" "$MAJOR" "$MINOR"
The main issue is quoting of the 'sed' expression. We had regex [0-9.],
but we want [0-9\.] so that we match a literal '.' as opposed to
anything. Or so I speculate. I made a script that output the version
info Hans has and after the patch it is fine.
More information about the U-Boot
mailing list