aboutsummaryrefslogtreecommitdiff
path: root/bin/fnl.sh
diff options
context:
space:
mode:
Diffstat (limited to 'bin/fnl.sh')
-rw-r--r--bin/fnl.sh20
1 files changed, 20 insertions, 0 deletions
diff --git a/bin/fnl.sh b/bin/fnl.sh
new file mode 100644
index 00000000..8d771adb
--- /dev/null
+++ b/bin/fnl.sh
@@ -0,0 +1,20 @@
+# Run a command and save its output and error to temporary files
+
+# Check we have at least one argument
+if [ "$#" -eq 0 ] ; then
+ printf >&2 'fnl: Command needed\n'
+ return 2
+fi
+
+# Create a temporary directory; note that we *don't* clean it up on exit
+dir=$(mktd fnl) || exit
+
+# Run the command; keep its exit status
+{ "$@" ; } >"$dir"/stdout 2>"$dir"/stderr
+ret=$?
+
+# Run wc(1) on each of the files
+wc -- "$dir"/*
+
+# Exit with the wrapped command's exit status
+exit "$ret"