[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master c40f2f8 14/18: Routinely run shellcheck
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master c40f2f8 14/18: Routinely run shellcheck |
Date: |
Wed, 29 May 2019 18:49:09 -0400 (EDT) |
branch: master
commit c40f2f888e900be8278626c428adea03c7f2d95f
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Routinely run shellcheck
Used 'xargs -P' in 'GNUmakefile' because it roughly quintuples the
speed of the command in which it occurs.
---
GNUmakefile | 1 +
check_script.sh | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 52 insertions(+)
diff --git a/GNUmakefile b/GNUmakefile
index 074fc46..b0766a4 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -454,6 +454,7 @@ check_concinnity: source_clean custom_tools
@$(LS) --classify $(prefascicle_dir)/* \
| $(SED) -e'/\*$$/!d' -e'/^\.\//!d' -e'/.sh\*$$/d' -e'/.sed\*$$/d' \
| $(SED) -e's/^/Improperly executable: /'
+ @find $(prefascicle_dir) -executable -type f -print0 | xargs -0 -n 1 -P
0 ./check_script.sh
@$(ECHO) " Problems detected by xmllint:"
@for z in $(xml_files); \
do \
diff --git a/check_script.sh b/check_script.sh
new file mode 100755
index 0000000..f0c4a09
--- /dev/null
+++ b/check_script.sh
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+# Use 'shellcheck' to test a shell script.
+
+# Copyright (C) 2019 Gregory W. Chicares.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+#
+# http://savannah.nongnu.org/projects/lmi
+# email: <address@hidden>
+# snail: Chicares, 186 Belle Woods Drive, Glastonbury CT 06033, USA
+
+# Skip:
+# - empty argument: no script to check
+# - git's default hooks: the maintainers don't use shellcheck
+# - tabs/ scripts: they're extraordinary
+
+case "$1" in
+ ("") exit 0 ;;
+ (*.git/hooks-orig*) exit 0 ;;
+ (*tabs/*/startup_script*) exit 0 ;;
+esac
+
+# First line, truncated at its first blank:
+shebang="$(sed -e'1!d' -e's/ .*$//' "$1")"
+case $shebang in
+ ("#!/bin/sh")
+ shellcheck --external-sources "$1"
+ ;;
+ ("#!/bin/zsh")
+ new_name="/tmp/$(basename "$1")$(date -u +'%s_%N').eraseme"
+ cp -a "$1" "$new_name"
+ sed -i "$new_name" -e'1s/zsh/sh/'
+ shellcheck --external-sources "$new_name"
+ rm "$new_name"
+ ;;
+ ("#!/usr/bin/make") ;;
+ ("#!/bin/sed") ;;
+ (*) printf '%s\n' "unknown shebang $shebang in file $1" ;;
+esac
- [lmi-commits] [lmi] master 0d8f53e 02/18: Resolve shellcheck "SC1117" warning, (continued)
- [lmi-commits] [lmi] master 0d8f53e 02/18: Resolve shellcheck "SC1117" warning, Greg Chicares, 2019/05/29
- [lmi-commits] [lmi] master 1d9b9a6 04/18: Deduplicate, Greg Chicares, 2019/05/29
- [lmi-commits] [lmi] master 0e9da3a 01/18: Use Ubuntu 18.04 only for WSL, Greg Chicares, 2019/05/29
- [lmi-commits] [lmi] master 66fe46b 03/18: Resolve more shellcheck "SC1117" warnings, Greg Chicares, 2019/05/29
- [lmi-commits] [lmi] master a4ee62f 07/18: Suppress certain shellcheck warnings, Greg Chicares, 2019/05/29
- [lmi-commits] [lmi] master b25a732 06/18: Resolve all shellcheck "SC2038" warnings, Greg Chicares, 2019/05/29
- [lmi-commits] [lmi] master d52c37f 09/18: Resolve a shellcheck "SC2034" warning, Greg Chicares, 2019/05/29
- [lmi-commits] [lmi] master ee293d1 10/18: Update certain URLs, Greg Chicares, 2019/05/29
- [lmi-commits] [lmi] master 19c0946 13/18: Copy compiler runtime files in one makefile target only, Greg Chicares, 2019/05/29
- [lmi-commits] [lmi] master 3873eb0 15/18: Fix defect committed 20190521T2101: tested 'md5sums' in wrong directory, Greg Chicares, 2019/05/29
- [lmi-commits] [lmi] master c40f2f8 14/18: Routinely run shellcheck,
Greg Chicares <=
- [lmi-commits] [lmi] master aebe56b 17/18: Don't copy compiler runtime files to build directory, Greg Chicares, 2019/05/29
- [lmi-commits] [lmi] master 9b9978f 16/18: Avoid 'ls --classify', Greg Chicares, 2019/05/29
- [lmi-commits] [lmi] master f4cb231 08/18: Remove space after '#!', Greg Chicares, 2019/05/29
- [lmi-commits] [lmi] master aa29114 12/18: Improve command to copy compiler runtime files, Greg Chicares, 2019/05/29
- [lmi-commits] [lmi] master f760e3d 11/18: Fix defect introduced 20190426T2304Z: wrong variable used, Greg Chicares, 2019/05/29
- [lmi-commits] [lmi] master b30b5db 18/18: Make 'custom_tools' when rebuilding from scratch, Greg Chicares, 2019/05/29
- [lmi-commits] [lmi] master 23ef51a 05/18: Resolve a shellcheck "SC2166" warning, Greg Chicares, 2019/05/29