1*febb0da5SEd Maste#!/bin/sh -u 2*febb0da5SEd Maste 3*febb0da5SEd Maste# Copyright (c) 2024 Google LLC. All rights reserved. 4*febb0da5SEd Maste# Use of this source code is governed by a BSD-style 5*febb0da5SEd Maste# license that can be found in the LICENSE file. 6*febb0da5SEd Maste# SPDX-License-Identifier: BSD-2-Clause 7*febb0da5SEd Maste 8*febb0da5SEd MasteLIST="$(mktemp)" 9*febb0da5SEd Mastetrap 'rm -- $LIST' EXIT 10*febb0da5SEd Maste 11*febb0da5SEd Mastegit ls-files | while read -r file; do 12*febb0da5SEd Maste if head -n1 "$file" | grep -q '^#!.*sh'; then 13*febb0da5SEd Maste if ! shellcheck -Cnever --norc "$file"; then 14*febb0da5SEd Maste echo "$file" >> "$LIST" 15*febb0da5SEd Maste fi 16*febb0da5SEd Maste fi 17*febb0da5SEd Mastedone 18*febb0da5SEd Maste 19*febb0da5SEd Maste[ -s "$LIST" ] && { 20*febb0da5SEd Maste echo "The following files contain errors:" 21*febb0da5SEd Maste cat "$LIST" 22*febb0da5SEd Maste exit 1 23*febb0da5SEd Maste} 1>&2 24*febb0da5SEd Maste 25*febb0da5SEd Masteexit 0 26