add opendir alias
[minix.git] / commands / ash / bltin / mkexpr.sh
blobc01483b503db36a0e0c8346bd7e235222e4f5953
1 #!/bin/sh
2 # Copyright 1989 by Kenneth Almquist. All rights reserved.
4 # This file is part of ash. Ash is distributed under the terms specified
5 # by the Ash General Public License. See the file named LICENSE.
7 # All calls to awk removed, because Minix bawk is deficient. (kjb)
9 if [ $# -ne 2 ]
10 then
11 echo "Usage: $0 <unary_op> <binary_op>" >&2
12 exit 1
14 unary_op="$1"
15 binary_op="$2"
17 exec > operators.h
18 i=0
19 sed -e '/^[^#]/!d' "$unary_op" "$binary_op" | while read line
21 set -$- $line
22 echo "#define $1 $i"
23 i=`expr $i + 1`
24 done
25 echo
26 echo "#define FIRST_BINARY_OP" `sed -e '/^[^#]/!d' "$unary_op" | wc -l`
27 echo '
28 #define OP_INT 1 /* arguments to operator are integer */
29 #define OP_STRING 2 /* arguments to operator are string */
30 #define OP_FILE 3 /* argument is a file name */
32 extern char *const unary_op[];
33 extern char *const binary_op[];
34 extern const char op_priority[];
35 extern const char op_argflag[];'
37 exec > operators.c
38 echo '/*
39 * Operators used in the expr/test command.
42 #include <stddef.h>
43 #include "shell.h"
44 #include "operators.h"
46 char *const unary_op[] = {'
47 sed -e '/^[^#]/!d
48 s/[ ][ ]*/ /g
49 s/^[^ ][^ ]* \([^ ][^ ]*\).*/ "\1",/
50 ' "$unary_op"
51 echo ' NULL
54 char *const binary_op[] = {'
55 sed -e '/^[^#]/!d
56 s/[ ][ ]*/ /g
57 s/^[^ ][^ ]* \([^ ][^ ]*\).*/ "\1",/
58 ' "$binary_op"
59 echo ' NULL
62 const char op_priority[] = {'
63 sed -e '/^[^#]/!d
64 s/[ ][ ]*/ /g
65 s/^[^ ][^ ]* [^ ][^ ]* \([^ ][^ ]*\).*/ \1,/
66 ' "$unary_op" "$binary_op"
67 echo '};
69 const char op_argflag[] = {'
70 sed -e '/^[^#]/!d
71 s/[ ][ ]*/ /g
72 s/^[^ ][^ ]* [^ ][^ ]* [^ ][^ ]*$/& 0/
73 s/^[^ ][^ ]* [^ ][^ ]* [^ ][^ ]* \([^ ][^ ]*\)/ \1,/
74 ' "$unary_op" "$binary_op"
75 echo '};'