This repository has been archived on 2024-07-19. You can view files and clone it, but cannot push or open issues or pull requests.
ale/stdin-wrapper
Bjorn Neergaard e68800a28d
Fixup stdin-wrapper
* Use a more universal shebang.
* Use the template feature of mktemp to avoid silly gymnastics.
2016-10-10 14:31:17 -05:00

20 lines
568 B
Bash
Executable file

#!/usr/bin/env bash
# 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 --tmpdir "ale-XXX$file_extension")
trap 'rm $temp_file' EXIT
while read -r; do
echo "$REPLY" >> "$temp_file"
done
"$@" "$temp_file"