23 lines
595 B
Bash
Executable File
23 lines
595 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -E -o errexit -o nounset -o pipefail
|
|
|
|
# Exit silently if required tools are missing
|
|
command -v shellcheck > /dev/null 2>&1 || exit 0
|
|
command -v file > /dev/null 2>&1 || exit 0
|
|
command -v jq > /dev/null 2>&1 || exit 0
|
|
|
|
input=$(cat)
|
|
file_path=$(printf '%s' "$input" | jq -r '.tool_input.file_path // empty')
|
|
|
|
[[ -z "$file_path" || ! -f "$file_path" ]] && exit 0
|
|
|
|
file_type=$(file --brief "$file_path")
|
|
case "$file_type" in
|
|
*"Bourne-Again shell"*|*"bash"*|*"/bin/bash"*) ;;
|
|
*"shell script"*|*"/bin/sh"*) ;;
|
|
*) exit 0 ;;
|
|
esac
|
|
|
|
shellcheck --format=gcc "$file_path" >&2
|