blob: 09e9436e9e4a3e81aa2828f67c31b1e8f4f1063e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#!/bin/bash -eu
# Author: w0rp <devw0rp@gmail.com>
# Description: This script implements a wrapper for any program which does not accept
# stdin input on most Unix machines. The input to the script is read to a
# temporary file, and the first argument sets a particular file extension
# for the temporary file.
# All of the following arguments are read as command to run.
file_extension="$1"
shift
temp_file=`mktemp`
mv "$temp_file" "$temp_file$file_extension"
temp_file="$temp_file$file_extension"
trap "rm $temp_file" EXIT
while read -r; do
echo "$REPLY" >> "$temp_file"
done
"$@" "$temp_file"
|