From 165c35c70b43349e882bd44be31c0837ab19729b Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 5 Apr 2017 21:08:39 +1200 Subject: More sh flexibility (check/lint scripts) --- check/bash | 6 ------ check/bash.sh | 5 +++++ check/bin | 14 -------------- check/bin.sh | 4 ++++ check/games | 14 -------------- check/games.sh | 4 ++++ check/ksh | 6 ------ check/ksh.sh | 5 +++++ check/man | 48 ------------------------------------------------ check/man.sh | 47 +++++++++++++++++++++++++++++++++++++++++++++++ check/sh | 6 ------ check/sh.sh | 5 +++++ check/urxvt | 9 --------- check/urxvt.sh | 4 ++++ check/yash | 6 ------ check/yash.sh | 5 +++++ check/zsh | 6 ------ check/zsh.sh | 5 +++++ 18 files changed, 84 insertions(+), 115 deletions(-) delete mode 100755 check/bash create mode 100644 check/bash.sh delete mode 100755 check/bin create mode 100644 check/bin.sh delete mode 100755 check/games create mode 100644 check/games.sh delete mode 100755 check/ksh create mode 100644 check/ksh.sh delete mode 100755 check/man create mode 100644 check/man.sh delete mode 100755 check/sh create mode 100644 check/sh.sh delete mode 100755 check/urxvt create mode 100644 check/urxvt.sh delete mode 100755 check/yash create mode 100644 check/yash.sh delete mode 100755 check/zsh create mode 100644 check/zsh.sh (limited to 'check') diff --git a/check/bash b/check/bash deleted file mode 100755 index 525bec34..00000000 --- a/check/bash +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -for bash in bash/* bash/bashrc.d/* ; do - [ -f "$bash" ] || continue - bash -n "$bash" || exit -done -printf 'All bash(1) scripts parsed successfully.\n' diff --git a/check/bash.sh b/check/bash.sh new file mode 100644 index 00000000..a3efccb1 --- /dev/null +++ b/check/bash.sh @@ -0,0 +1,5 @@ +for bash in bash/* bash/bashrc.d/* ; do + [ -f "$bash" ] || continue + bash -n "$bash" || exit +done +printf 'All bash(1) scripts parsed successfully.\n' diff --git a/check/bin b/check/bin deleted file mode 100755 index 2fc4e767..00000000 --- a/check/bin +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -for bin in bin/* ; do - [ -x "$bin" ] || continue - hb=$(sed 1q "$bin") || exit - case $hb in - *bash) - bash -n "$bin" || exit - ;; - *sh) - sh -n "$bin" || exit - ;; - esac -done -printf 'All shell scripts in bin parsed successfully.\n' diff --git a/check/bin.sh b/check/bin.sh new file mode 100644 index 00000000..04b0da6b --- /dev/null +++ b/check/bin.sh @@ -0,0 +1,4 @@ +for bin in bin/*.sh ; do + sh -n "$bin" || exit +done +printf 'All shell scripts in bin parsed successfully.\n' diff --git a/check/games b/check/games deleted file mode 100755 index d3b5feac..00000000 --- a/check/games +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -for game in games/* ; do - [ -x "$game" ] || continue - hb=$(sed 1q "$game") || exit - case $hb in - *bash) - bash -n "$game" || exit - ;; - *sh) - sh -n "$game" || exit - ;; - esac -done -printf 'All shell scripts in games parsed successfully.\n' diff --git a/check/games.sh b/check/games.sh new file mode 100644 index 00000000..79d53ed5 --- /dev/null +++ b/check/games.sh @@ -0,0 +1,4 @@ +for game in games/*.sh ; do + sh -n "$game" || exit +done +printf 'All shell scripts in games parsed successfully.\n' diff --git a/check/ksh b/check/ksh deleted file mode 100755 index 3136c413..00000000 --- a/check/ksh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -for ksh in ksh/* ksh/kshrc.d/* ; do - [ -f "$ksh" ] || continue - ksh -n "$ksh" || exit -done -printf 'All ksh scripts parsed successfully.\n' diff --git a/check/ksh.sh b/check/ksh.sh new file mode 100644 index 00000000..51e71e19 --- /dev/null +++ b/check/ksh.sh @@ -0,0 +1,5 @@ +for ksh in ksh/* ksh/kshrc.d/* ; do + [ -f "$ksh" ] || continue + ksh -n "$ksh" || exit +done +printf 'All ksh scripts parsed successfully.\n' diff --git a/check/man b/check/man deleted file mode 100755 index ca1c248c..00000000 --- a/check/man +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/sh -# Check that manual pages and logical binaries match up - -# Need some scripts from the source directory -PATH=bin:$PATH - -# Create temporary directory and implement cleanup function for it -td= -cleanup() { - rm -fr -- "$td" -} -for sig in EXIT HUP INT TERM ; do - trap cleanup "$sig" -done -td=$(mktd test-man) || exit - -# Get lists of logical binaries and manual pages -# shellcheck disable=SC2016 -find bin games -type f -print | - sed 's_.*/__;s_\..*$__' | - sort | uniq > "$td"/bin -# shellcheck disable=SC2016 -find man/man[168] -type f -name '*.[168]df' -print | - sed 's_.*/__;s_\..*$__' | - sort | uniq > "$td"/man - -# Get lists of noman scripts and nobin manual pages -comm -23 "$td"/bin "$td"/man > "$td"/noman -comm -13 "$td"/bin "$td"/man > "$td"/nobin - -# Emit the content of both, if any -ex=0 -if [ -s "$td"/noman ] ; then - printf >&2 'No manual pages found for:\n' - cat >&2 -- "$td"/noman - ex=1 -fi -if [ -s "$td"/nobin ] ; then - printf >&2 'Stray manual page for:\n' - cat >&2 -- "$td"/nobin - ex=1 -fi - -# Exit appropriately -if [ "$ex" -eq 0 ] ; then - printf 'All scripts have manual pages.\n' -fi -exit "$ex" diff --git a/check/man.sh b/check/man.sh new file mode 100644 index 00000000..89c03890 --- /dev/null +++ b/check/man.sh @@ -0,0 +1,47 @@ +# Check that manual pages and logical binaries match up + +# Need some scripts from the source directory +PATH=bin:$PATH + +# Create temporary directory and implement cleanup function for it +td= +cleanup() { + rm -fr -- "$td" +} +for sig in EXIT HUP INT TERM ; do + trap cleanup "$sig" +done +td=$(mktd test-man) || exit + +# Get lists of logical binaries and manual pages +# shellcheck disable=SC2016 +find bin games -type f -print | + sed 's_.*/__;s_\..*$__' | + sort | uniq > "$td"/bin +# shellcheck disable=SC2016 +find man/man[168] -type f -name '*.[168]df' -print | + sed 's_.*/__;s_\..*$__' | + sort | uniq > "$td"/man + +# Get lists of noman scripts and nobin manual pages +comm -23 "$td"/bin "$td"/man > "$td"/noman +comm -13 "$td"/bin "$td"/man > "$td"/nobin + +# Emit the content of both, if any +ex=0 +if [ -s "$td"/noman ] ; then + printf >&2 'No manual pages found for:\n' + cat >&2 -- "$td"/noman + ex=1 +fi +if [ -s "$td"/nobin ] ; then + printf >&2 'Stray manual page for:\n' + cat >&2 -- "$td"/nobin + ex=1 +fi + +# Exit appropriately +if [ "$ex" -eq 0 ] ; then + printf 'All scripts have manual pages.\n' +fi +exit "$ex" diff --git a/check/sh b/check/sh deleted file mode 100755 index ec3ba339..00000000 --- a/check/sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -for sh in sh/* sh/profile.d/* sh/shrc.d/* ; do - [ -f "$sh" ] || continue - sh -n "$sh" || exit -done -printf 'All sh(1) scripts parsed successfully.\n' diff --git a/check/sh.sh b/check/sh.sh new file mode 100644 index 00000000..53d8c4b6 --- /dev/null +++ b/check/sh.sh @@ -0,0 +1,5 @@ +for sh in sh/* sh/profile.d/* sh/shrc.d/* ; do + [ -f "$sh" ] || continue + sh -n "$sh" || exit +done +printf 'All sh(1) scripts parsed successfully.\n' diff --git a/check/urxvt b/check/urxvt deleted file mode 100755 index a40f8559..00000000 --- a/check/urxvt +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -for perl in urxvt/ext/* ; do - [ -f "$perl" ] || continue - case $perl in - *.pl) ;; - *) perl -c "$perl" >/dev/null || exit ;; - esac -done -printf 'All Perl scripts in urxvt/ext parsed successfully.\n' diff --git a/check/urxvt.sh b/check/urxvt.sh new file mode 100644 index 00000000..ee39e6c9 --- /dev/null +++ b/check/urxvt.sh @@ -0,0 +1,4 @@ +for perl in urxvt/ext/*.pl ; do + perl -c "$perl" || exit +done +printf 'All Perl scripts in urxvt/ext parsed successfully.\n' diff --git a/check/yash b/check/yash deleted file mode 100755 index fb737596..00000000 --- a/check/yash +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -for yash in yash/* ; do - [ -f "$yash" ] || continue - yash -n "$yash" || exit -done -printf 'All yash scripts parsed successfully.\n' diff --git a/check/yash.sh b/check/yash.sh new file mode 100644 index 00000000..c8722f3d --- /dev/null +++ b/check/yash.sh @@ -0,0 +1,5 @@ +for yash in yash/* ; do + [ -f "$yash" ] || continue + yash -n "$yash" || exit +done +printf 'All yash scripts parsed successfully.\n' diff --git a/check/zsh b/check/zsh deleted file mode 100755 index 39a6c1e9..00000000 --- a/check/zsh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -for zsh in zsh/* zsh/zshrc.d/* ; do - [ -f "$zsh" ] || continue - zsh -n "$zsh" || exit -done -printf 'All zsh(1) scripts parsed successfully.\n' diff --git a/check/zsh.sh b/check/zsh.sh new file mode 100644 index 00000000..50335d56 --- /dev/null +++ b/check/zsh.sh @@ -0,0 +1,5 @@ +for zsh in zsh/* zsh/zshrc.d/* ; do + [ -f "$zsh" ] || continue + zsh -n "$zsh" || exit +done +printf 'All zsh(1) scripts parsed successfully.\n' -- cgit v1.2.3