From cb3dac04e9ca59b315230265b127042d0c8c96ac Mon Sep 17 00:00:00 2001 From: DTB Date: Mon, 15 Jan 2024 14:26:23 -0700 Subject: [PATCH] more work on tee and also a cat too --- mm/cat | 17 +++++++++++++++++ mm/tee | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100755 mm/cat diff --git a/mm/cat b/mm/cat new file mode 100755 index 0000000..127da4f --- /dev/null +++ b/mm/cat @@ -0,0 +1,17 @@ +#!/bin/sh + +while getopts :u c +do case "$c" in + u) line="$(printf '%s -u ' "$line")" ;; + *) printf 'Usage: %s (-hu) (file...)\n' "$0" + exit 64 # sysexits(3) EX_USAGE + esac +done + +shift "$(printf '%s - 1\n' "$OPTIND" | bc)" + +for file in "$@"; +do line="$(printf '%s -i %s ' "$line" "$file")" +done + +exec mm $line diff --git a/mm/tee b/mm/tee index 34093d3..7e649c1 100755 --- a/mm/tee +++ b/mm/tee @@ -4,7 +4,7 @@ while getopts :ai c do case "$c" in a) line="$(printf '%s -a ' "$line")" ;; i) line="$(printf '%s -n ' "$line")" ;; - *) printf 'Usage: %s (-ai) (file...)\n' "$0" + *) printf 'Usage: %s (-ahi) (file...)\n' "$0" exit 64 # sysexits(3) EX_USAGE esac done