ale/stdin-wrapper

21 lines
574 B
Plaintext
Raw Normal View History

#!/usr/bin/env bash
2016-10-03 14:20:13 -04:00
# 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.
2016-10-03 14:20:13 -04:00
# All of the following arguments are read as command to run.
file_extension="$1"
shift
2016-10-10 16:53:56 -04:00
temp_file=$(mktemp --tmpdir "ale-XXXXXXXXX$file_extension")
trap 'rm $temp_file' EXIT
while read -r; do
echo "$REPLY" >> "$temp_file"
done
"$@" "$temp_file"