Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/conf Use shell builtins instead of awk and sed.
details: https://anonhg.NetBSD.org/src/rev/c212bb427f67
branches: trunk
changeset: 749044:c212bb427f67
user: dsl <dsl%NetBSD.org@localhost>
date: Sun Nov 15 13:39:00 2009 +0000
description:
Use shell builtins instead of awk and sed.
Avoids problems with awk processing floating point numbers when LC_NUMERIC
give a decimal point of ','.
Fixes PR/42321
diffstat:
sys/conf/osrelease.sh | 41 ++++++++++++++++++++++++++++-------------
1 files changed, 28 insertions(+), 13 deletions(-)
diffs (67 lines):
diff -r 7a7d8eae2465 -r c212bb427f67 sys/conf/osrelease.sh
--- a/sys/conf/osrelease.sh Sun Nov 15 12:26:02 2009 +0000
+++ b/sys/conf/osrelease.sh Sun Nov 15 13:39:00 2009 +0000
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# $NetBSD: osrelease.sh,v 1.117 2009/10/29 06:33:27 apb Exp $
+# $NetBSD: osrelease.sh,v 1.118 2009/11/15 13:39:00 dsl Exp $
#
# Copyright (c) 1997 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -32,28 +32,43 @@
# We use the number specified in <sys/param.h>
-AWK=${AWK:-awk}
-SED=${TOOL_SED:-sed}
-PARAMH="`dirname $0`"/../sys/param.h
-release=`$AWK '/^#define[ ]*__NetBSD_Version__/ { print $6 }' $PARAMH`
+path="./$0"
+exec < ${path%/*}/../sys/param.h
+
+while
+ read define ver_tag release comment || exit 1
+do
+ [ "$define" = "#define" ] || continue;
+ [ "$ver_tag" = "__NetBSD_Version__" ] || continue
+ break
+done
-# default: return nn.nn.nn
-# -m: return nn, representing only the major number; however, for -current,
+# ${release} is [M]Mmm00pp00
+#
+# default: return MM.mm.pp
+# -m: return MM, representing only the major number; however, for -current,
# return the next major number (e.g. for 5.99.nn, return 6)
-# -n: return nn.nn
-# -s: return nnnnnn (no dots)
+# -n: return MM.mm
+# -s: return MMmmpp (no dots)
+
+release=${release%??}
+
+rel_MMmm=${release%????}
+rel_MM=${rel_MMmm%??}
+rel_mm=${rel_MMmm#${rel_MM}}
+rel_pp=${release#${rel_MMmm}00}
case $1 in
-m)
- echo $release | $AWK -F. '{print int($1+$2/100+0.01)}'
+ echo "$(((${rel_MMmm}+1)/100))"
;;
-n)
- echo $release | $AWK -F. '{print $1 "." $2}'
+ echo "$rel_MM.$rel_mm"
;;
-s)
- echo $release | $SED -e 's,\.,,g'
+ echo "$rel_MM$rel_mm$rel_pp"
;;
*)
- echo $release
+ echo "$rel_MM.$rel_mm.$rel_pp"
;;
esac
Home |
Main Index |
Thread Index |
Old Index