From f6ceb7e3972e08c1f554aa683ac19fa6e6d621c9 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Tue, 6 Feb 2024 00:12:15 -0600 Subject: Various changes --- subtext.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'subtext.sh') diff --git a/subtext.sh b/subtext.sh index d845955..a60f0d6 100755 --- a/subtext.sh +++ b/subtext.sh @@ -1,7 +1,7 @@ #!/bin/sh stawk() { - awk -f subtext.awk "$@" # SUBTEXT AWK SCRIPT HERE + awk -f subtext.awk "$@" } usage() { @@ -23,14 +23,17 @@ configure() { : "${ST_MACROFILE:=}" : "${ST_SOPATH:=.:$HOME/.subtext}" : "${ST_PIPE_SH:=true}" + : "${ST_TRACE=+x}" ## Process options - while getopts :hm:I:n OPT + while getopts :hm:I:no:x OPT do case "$OPT" in (h) usage ;; - (m) ST_MACROFILE="$OPTARG" ;; + (m) ST_MACROFILE="$OPTARG.st.sh" ;; (I) ST_SOPATH="$ST_SOPATH:$OPTARG" ;; (n) ST_PIPE_SH=false ;; + (o) exec > "$OPTARG" ;; + (x) ST_TRACE=-x ;; (:) printf >&2 'Unknown option -%s\n' "$OPTARG"; usage 1 ;; (*) usage 1 ;; @@ -41,9 +44,9 @@ configure() { main() { configure "$@" shift $((OPTIND-1)) - stawk -vsopath="$ST_SOPATH" "$@" | + stawk -vsopath="$ST_SOPATH" -vsofile="$ST_MACROFILE" "$@" | if "$ST_PIPE_SH" - then sh + then sh "$ST_TRACE" else cat fi } -- cgit 1.4.1-21-gabe81