#! /bin/sh
-# $Id: MKkey_defs.sh,v 1.17 2019/03/02 22:51:42 tom Exp $
+# $Id: MKkey_defs.sh,v 1.19 2020/02/02 23:34:34 tom Exp $
##############################################################################
-# Copyright (c) 2001-2017,2019 Free Software Foundation, Inc. #
+# Copyright 2019,2020 Thomas E. Dickey #
+# Copyright 2001-2013,2017 Free Software Foundation, Inc. #
# #
# Permission is hereby granted, free of charge, to any person obtaining a #
# copy of this software and associated documentation files (the "Software"), #
# Extract function-key definitions from the Caps file
#
: ${AWK-awk}
-DATA=${1-Caps}
+
+test $# = 0 && set Caps
data=data$$
pass1=pass1_$$
# change repeated tabs (used for readability) to single tabs (needed to make
# awk see the right field alignment of the corresponding columns):
-if sort -k 6 $DATA >$data 2>/dev/null
+if sort -k 6 "$@" >$data 2>/dev/null
then
# POSIX
- sed -e 's/[ ][ ]*/ /g' < $DATA |sort -n -k 6 >$data
-elif sort -n +5 $DATA >$data 2>/dev/null
+ sed -e 's/[ ][ ]*/ /g' "$@" |sort -n -k 6 >$data
+elif sort -n +5 "$@" >$data 2>/dev/null
then
# SunOS (and SVr4, marked as obsolete but still recognized)
- sed -e 's/[ ][ ]*/ /g' < $DATA |sort -n +5 >$data
+ sed -e 's/[ ][ ]*/ /g' "$@" |sort -n +5 >$data
else
echo "Your sort utility is broken. Please install one that works." >&2
exit 1
EOF
THIS=./`basename $0`
-PARM=./`basename $DATA`
cat <<EOF
/*
- * These definitions were generated by $THIS $PARM
+ * These definitions were generated by $THIS $*
*/
EOF
/^#/ {next;}
/^capalias/ {next;}
/^infoalias/ {next;}
+/^used_by/ {next;}
+/^userdef/ {next;}
$5 != "-" && $6 != "-" {
if ($6 == "+") {