Skip to content

Instantly share code, notes, and snippets.

@maxmanders
Created September 24, 2017 14:43
Show Gist options
  • Save maxmanders/6bb5cda1afc4d8c4899e534ed8fce999 to your computer and use it in GitHub Desktop.
Save maxmanders/6bb5cda1afc4d8c4899e534ed8fce999 to your computer and use it in GitHub Desktop.
ZSH CI
max at maxmanders-laptop in ~/dev/dotfiles (master)
$ cat test.sh
#!/bin/bash
set -e
set -o pipefail
ZSH=$(which zsh)
BASH=$(which bash)
ERRORS=()
# find all shebang files
for f in $(
find . -path ./.oh-my-zsh -prune -o \
-path ./bin -prune -o \
-type f -not -iwholename '*.git*' \
-exec awk '/^#!\//{print FILENAME} {nextfile}' {} + | sort -u); do
# shellcheck disable=SC1001
if file "$f" | \grep -E --quiet "shell|zsh"; then
{
shellcheck <(sed "s|#\!${ZSH}|#\!${BASH}|g" < "${f}") && echo " [ok]: linted ${f}"
}\
||\
{
ERRORS+=("${f}")
}
fi
done
if [ ${#ERRORS[@]} -eq 0 ]; then
echo " [ok]: no errors found"
else
echo "[fail]: these files failed shellcheck: ${ERRORS[*]}"
exit 1
fi
max at maxmanders-laptop in ~/dev/dotfiles (master)
$ ./test.sh
[ok]: linted ./.zshrc
[ok]: linted ./.zshrc.d/aliases.zshrc
[ok]: linted ./.zshrc.d/exports.zshrc
[ok]: linted ./.zshrc.d/functions.zshrc
[ok]: linted ./.zshrc.d/hosts.zshrc
[ok]: linted ./.zshrc.d/keybindings.zshrc
[ok]: linted ./test.sh
[ok]: no errors found
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment