-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcompile
More file actions
executable file
·43 lines (32 loc) · 785 Bytes
/
Copy pathcompile
File metadata and controls
executable file
·43 lines (32 loc) · 785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/sh
usage() {
cat <<EOF
usage: $basename [sed script file]
Translate a sed script to C and compile the result to produce a standalone
binary reproducing the script behavior.
If no file is provided the sed code to be translated will be read from stdin.
EOF
exit "${1-0}"
}
readonly basename="${0##*/}"
for arg do
case "$arg" in
--help|-h)
usage
;;
*)
if ! [ -e "$arg" ]; then
printf '%s: %s: No such file or directory\n' "$basename" "$arg"
usage 1
fi >&2
;;
esac
done
readonly translator=./par.sed
readonly generated_file=generated.c
readonly bin="${BIN-./sed-bin}"
set -x
cat "$@" | "$translator" > "$generated_file"
make
{ set +x; } 2> /dev/null
echo Compiled sed script available: "$bin"