commit fe4243635c875b80889fd6a8d8f4788026d2c1d0 parent 55665e16637788c61b6f3fb29d87ee2f43801d69 Author: Jacob R. Edwards <n/a> Date: Fri, 9 Dec 2022 11:16:05 -0600 Add script to provide stdin as a seekable file Useful for pesky programs which require seekable files, and even for very pesky programs which require seekable files with certain names such as 'name.pdf' instead of simply 'name'. Diffstat:
| A | local/bin/bin/name | | | 26 | ++++++++++++++++++++++++++ |
1 file changed, 26 insertions(+), 0 deletions(-)
diff --git a/local/bin/bin/name b/local/bin/bin/name @@ -0,0 +1,26 @@ +#!/bin/sh +# Copyright 2022 Jacob R. Edwards +# Provide a stdin as a regular file to a program +# +# The purpose of this is to provide a way to use programs which +# require seekable files, potentially with specific names, in a +# pipeline. + +set -e + +name=name +case "$1" in +(--) shift ;; +(-n) name="$2"; shift 2 ;; +(-*) + echo "$1: Invalid option +usage: $(basename "$0") [-n name] command [args ...]" 1>&2 + exit 1 +esac + +dir="$(mktemp -d pipe-XXXXXX)" +trap 'rm -r "$dir"' SIGINT SIGTERM 0 +path="$dir/$name" + +cat > "$path" +"$@" "$path"