|
| 1 | +#/ |
| 2 | +# @license Apache-2.0 |
| 3 | +# |
| 4 | +# Copyright (c) 2018 The Stdlib Authors. |
| 5 | +# |
| 6 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | +# you may not use this file except in compliance with the License. |
| 8 | +# You may obtain a copy of the License at |
| 9 | +# |
| 10 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +# |
| 12 | +# Unless required by applicable law or agreed to in writing, software |
| 13 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +# See the License for the specific language governing permissions and |
| 16 | +# limitations under the License. |
| 17 | +#/ |
| 18 | + |
| 19 | +# VARIABLES # |
| 20 | + |
| 21 | +# Define the command flags: |
| 22 | +FIND_SHELL_FLAGS ?= \ |
| 23 | + -type f \ |
| 24 | + \( -name "$(SHELL_PATTERN)" -o ! -name "*.*" \) \ |
| 25 | + -regex "$(SHELL_FILTER)" \ |
| 26 | + $(FIND_FILES_EXCLUDE_FLAGS) |
| 27 | + |
| 28 | +ifneq ($(OS), Darwin) |
| 29 | + FIND_SHELL_FLAGS := -regextype posix-extended $(FIND_SHELL_FLAGS) |
| 30 | +endif |
| 31 | + |
| 32 | +# Define a command for listing shell script files: |
| 33 | +FIND_SHELL_CMD ?= find $(find_kernel_prefix) $(ROOT_DIR) $(FIND_SHELL_FLAGS) |
| 34 | + |
| 35 | +# Define the list of files: |
| 36 | +SHELL_FILES ?= $(shell $(FIND_SHELL_CMD) | while read -r file; do head -n1 "$$file" | grep -q '^\#\!/usr/bin/env bash' && echo "$$file"; done) |
| 37 | + |
| 38 | + |
| 39 | +# RULES # |
| 40 | + |
| 41 | +#/ |
| 42 | +# Lists all shell script files. |
| 43 | +# |
| 44 | +# @example |
| 45 | +# make list-shell-files |
| 46 | +#/ |
| 47 | +list-shell-files: |
| 48 | + $(QUIET) find $(find_kernel_prefix) $(ROOT_DIR) $(FIND_SHELL_FLAGS) $(find_print_list) | while read -r file; do \ |
| 49 | + head -n1 "$$file" | \ |
| 50 | + grep -q "^#\!/usr/bin/env bash" && \ |
| 51 | + echo "$$file" || continue; \ |
| 52 | + done |
| 53 | + |
| 54 | +.PHONY: list-shell-files |
0 commit comments