mirror of https://github.com/dense-analysis/ale
29 lines
884 B
Bash
Executable File
29 lines
884 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
|
|
|
|
# In perfect world it wouldn't be needed, but some tools (`go vet`, I am looking
|
|
# at you) do not fit in line and require filename ending. Otherwise it would be
|
|
# simple as
|
|
#
|
|
# "$@" /dev/stdin
|
|
#
|
|
# without all that hackery with copying `/dev/stdin`
|
|
cp /dev/stdin "$temp_file"
|
|
|
|
"$@" "$temp_file"
|