summaryrefslogtreecommitdiff
path: root/stdin-wrapper
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2016-09-18 23:58:04 +0100
committerw0rp <devw0rp@gmail.com>2016-09-18 23:58:04 +0100
commit57ef2c98339af5fd40e99e44c420815f9ed0805f (patch)
tree8d3e085f9140576a9d6e4e04ad703154f84412a0 /stdin-wrapper
parente0fc0c7bb607760daa70ddd1a31fe1f30663e91f (diff)
downloadale-57ef2c98339af5fd40e99e44c420815f9ed0805f.zip
Add support for checking Haskell code via a wrapper script which can be used for other tools, and fix a readline problem with the DMD wrapper script.
Diffstat (limited to 'stdin-wrapper')
-rwxr-xr-xstdin-wrapper23
1 files changed, 23 insertions, 0 deletions
diff --git a/stdin-wrapper b/stdin-wrapper
new file mode 100755
index 00000000..b3f9a2f9
--- /dev/null
+++ b/stdin-wrapper
@@ -0,0 +1,23 @@
+#!/bin/bash -eu
+
+# 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; do
+ echo "$REPLY" >> "$temp_file"
+done
+
+"$@" "$temp_file"