Module Name: src
Committed By: christos
Date: Fri Apr 5 22:22:17 UTC 2024
Modified Files:
src/bin/sh: mkoptions.sh
Log Message:
>From Jan-Benedict Glaw:
Fix a redirection and prepare a stable sort for upper-/lowercase
option letters
This script is a mess, I strongly believe that it should be rewritten.
However, I'm not 100% sure why it was invented in the first place
(come on, the generated header file isn't _that_ complicated that
it couldn't be sanely managed by hand!), but let's fix the sorting
order by using LC_ALL=C.
Also add a few 'X' to the `mktemp` template to make non-BSD
implementations happy. As a bonus, actually *use* the initial `sed`
output instead of throwing it away by piping it into `sort` with
also connecting `sort`'s stdin with the original input file...
To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/bin/sh/mkoptions.sh
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/bin/sh/mkoptions.sh
diff -u src/bin/sh/mkoptions.sh:1.5 src/bin/sh/mkoptions.sh:1.6
--- src/bin/sh/mkoptions.sh:1.5 Wed Nov 15 04:21:19 2017
+++ src/bin/sh/mkoptions.sh Fri Apr 5 18:22:17 2024
@@ -1,6 +1,6 @@
#! /bin/sh
-# $NetBSD: mkoptions.sh,v 1.5 2017/11/15 09:21:19 kre Exp $
+# $NetBSD: mkoptions.sh,v 1.6 2024/04/05 22:22:17 christos Exp $
#
# It would be more sensible to generate 2 .h files, one which
@@ -13,12 +13,13 @@
set -f
IFS=' ' # blank, tab (no newline)
+export LC_ALL=C # for sort consistency
IF="$1"
OF="${3+$3/}$2"
-E_FILE=$(${MKTEMP:-mktemp} -t MKO.E.$$)
-O_FILE=$(${MKTEMP:-mktemp} -t MKO.O.$$)
+E_FILE=$(${MKTEMP:-mktemp} -t MKOXXXXXXXX.E.$$)
+O_FILE=$(${MKTEMP:-mktemp} -t MKOXXXXXXXX.O.$$)
trap 'rm -f "${E_FILE}" "${O_FILE}"' EXIT
exec 5> "${E_FILE}"
@@ -40,8 +41,8 @@ ${SED:-sed} <"${IF}" \
-e '/^#/d' \
-e '/^[ ]*\//d' \
-e '/^[ ]*\*/d' \
- -e '/^[ ]*;/d' |
-sort -b -k2,2f -k2,2 < "${IF}" |
+ -e '/^[ ]*;/d' |
+sort -b -k2,2f -k2,2 |
while read line
do
# Look for comments in various styles, and ignore them