diff options
Diffstat (limited to 'subtext.sh')
-rwxr-xr-x | subtext.sh | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/subtext.sh b/subtext.sh index d845955..a60f0d6 100755 --- a/subtext.sh +++ b/subtext.sh | |||
@@ -1,7 +1,7 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | 2 | ||
3 | stawk() { | 3 | stawk() { |
4 | awk -f subtext.awk "$@" # SUBTEXT AWK SCRIPT HERE | 4 | awk -f subtext.awk "$@" |
5 | } | 5 | } |
6 | 6 | ||
7 | usage() { | 7 | usage() { |
@@ -23,14 +23,17 @@ configure() { | |||
23 | : "${ST_MACROFILE:=}" | 23 | : "${ST_MACROFILE:=}" |
24 | : "${ST_SOPATH:=.:$HOME/.subtext}" | 24 | : "${ST_SOPATH:=.:$HOME/.subtext}" |
25 | : "${ST_PIPE_SH:=true}" | 25 | : "${ST_PIPE_SH:=true}" |
26 | : "${ST_TRACE=+x}" | ||
26 | ## Process options | 27 | ## Process options |
27 | while getopts :hm:I:n OPT | 28 | while getopts :hm:I:no:x OPT |
28 | do | 29 | do |
29 | case "$OPT" in | 30 | case "$OPT" in |
30 | (h) usage ;; | 31 | (h) usage ;; |
31 | (m) ST_MACROFILE="$OPTARG" ;; | 32 | (m) ST_MACROFILE="$OPTARG.st.sh" ;; |
32 | (I) ST_SOPATH="$ST_SOPATH:$OPTARG" ;; | 33 | (I) ST_SOPATH="$ST_SOPATH:$OPTARG" ;; |
33 | (n) ST_PIPE_SH=false ;; | 34 | (n) ST_PIPE_SH=false ;; |
35 | (o) exec > "$OPTARG" ;; | ||
36 | (x) ST_TRACE=-x ;; | ||
34 | (:) printf >&2 'Unknown option -%s\n' "$OPTARG"; | 37 | (:) printf >&2 'Unknown option -%s\n' "$OPTARG"; |
35 | usage 1 ;; | 38 | usage 1 ;; |
36 | (*) usage 1 ;; | 39 | (*) usage 1 ;; |
@@ -41,9 +44,9 @@ configure() { | |||
41 | main() { | 44 | main() { |
42 | configure "$@" | 45 | configure "$@" |
43 | shift $((OPTIND-1)) | 46 | shift $((OPTIND-1)) |
44 | stawk -vsopath="$ST_SOPATH" "$@" | | 47 | stawk -vsopath="$ST_SOPATH" -vsofile="$ST_MACROFILE" "$@" | |
45 | if "$ST_PIPE_SH" | 48 | if "$ST_PIPE_SH" |
46 | then sh | 49 | then sh "$ST_TRACE" |
47 | else cat | 50 | else cat |
48 | fi | 51 | fi |
49 | } | 52 | } |