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
purpleP 60b89abd9c changed while read -r loop to cat > for portability and simplicity (#165)
* changed while read -r loop to cat > for portability and simplicity

* typo fix
2016-11-05 20:43:57 +00:00

21 lines
624 B
Bash
Executable file

#!/usr/bin/env bash
# Authors: w0rp <devw0rp@gmail.com>, hauleth <lukasz@niemier.pl>
# 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.
set -eu
# All of the following arguments are read as command to run.
file_extension="$1"
shift
temp_dir=$(mktemp -d 2>/dev/null || mktemp -d -t 'ale_linter')
temp_file="$temp_dir/file$file_extension"
trap 'rm -r "$temp_dir"' EXIT
cat > "$temp_file"
"$@" "$temp_file"