aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-08-01 22:07:39 +1200
committerTom Ryder <tom@sanctum.geek.nz>2016-08-01 22:07:39 +1200
commit51d75ea05040c230eb9e11d5d97e56fb3b5b42d7 (patch)
tree6de8b424e6116f2c1f26701f53ce8a6c67073d13 /bin
parentHave dub(1) include dotfiles (diff)
downloaddotfiles-51d75ea05040c230eb9e11d5d97e56fb3b5b42d7.tar.gz
dotfiles-51d75ea05040c230eb9e11d5d97e56fb3b5b42d7.zip
Trim ax(1) down a bit
Diffstat (limited to 'bin')
-rwxr-xr-xbin/ax23
1 files changed, 4 insertions, 19 deletions
diff --git a/bin/ax b/bin/ax
index 3840acf5..8dea72da 100755
--- a/bin/ax
+++ b/bin/ax
@@ -1,14 +1,7 @@
#!/bin/sh
+# Evaluate an Awk expression given on the command line with an optional format
-# ax(1): Evaluate an Awk expression given on the command line with an optional
-# format.
-
-# Usage function
-usage() {
- printf 'ax: USAGE: ax [format] expression\n'
-}
-
-# Check number of arguments
+# Count arguments
case $# in
# If one argument, we assume format is %s
@@ -19,19 +12,11 @@ case $# in
# Any other number of arguments is wrong
*)
- usage >&2
+ printf >&2 'ax: Need an expression\n'
exit 2
;;
esac
-# Give help if requested
-case $1 in
- -h|--help|-\?)
- usage
- exit 0
- ;;
-esac
-
# Form program
prog=$(printf '
BEGIN {
@@ -39,5 +24,5 @@ prog=$(printf '
}
' "$form" "$expr")
-# Run the program
+# Run program
awk "$prog"