Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub Actions with ShellCheck #951

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
Fix SC2155
Fix SC2155: Declare and assign separately to avoid masking return values.

https://www.shellcheck.net/wiki/SC2155
asbjornu committed Jul 8, 2021
commit e18d3b844ec98edd44e8a3cf2849118f296ff6e2
3 changes: 2 additions & 1 deletion .exports
Original file line number Diff line number Diff line change
@@ -32,7 +32,8 @@ export MANPAGER='less -X';

# Avoid issues with `gpg` as installed via Homebrew.
# https://stackoverflow.com/a/42265848/96656
export GPG_TTY=$(tty);
GPG_TTY=$(tty);
export GPG_TTY

# Hide the “default interactive shell is now zsh” warning on macOS.
export BASH_SILENCE_DEPRECATION_WARNING=1;
23 changes: 14 additions & 9 deletions .functions
Original file line number Diff line number Diff line change
@@ -68,7 +68,8 @@ fi;

# Create a data URL from a file
function dataurl() {
local mimeType=$(file -b --mime-type "$1");
local mimeType;
mimeType=$(file -b --mime-type "$1");
if [[ $mimeType == text/* ]]; then
mimeType="${mimeType};charset=utf-8";
fi
@@ -87,17 +88,19 @@ function server() {
# Start a PHP server from a directory, optionally specifying the port
# (Requires PHP 5.4.0+.)
function phpserver() {
local port="${1:-4000}";
local ip=$(ipconfig getifaddr en1);
local port, ip;
port="${1:-4000}";
ip=$(ipconfig getifaddr en1);
sleep 1 && open "http://${ip}:${port}/" &
php -S "${ip}:${port}";
}

# Compare original and gzipped file size
function gz() {
local origsize=$(wc -c < "$1");
local gzipsize=$(gzip -c "$1" | wc -c);
local ratio=$(echo "$gzipsize * 100 / $origsize" | bc -l);
local origsize, gzipsize, ratio;
origsize=$(wc -c < "$1");
gzipsize=$(gzip -c "$1" | wc -c);
ratio=$(echo "$gzipsize * 100 / $origsize" | bc -l);
printf "orig: %d bytes\n" "$origsize";
printf "gzip: %d bytes (%2.2f%%)\n" "$gzipsize" "$ratio";
}
@@ -115,15 +118,17 @@ function getcertnames() {
return 1;
fi;

local domain="${1}";
local domain, tmp, certText;

domain="${1}";
echo "Testing ${domain}…";
echo ""; # newline

local tmp=$(echo -e "GET / HTTP/1.0\nEOT" \
tmp=$(echo -e "GET / HTTP/1.0\nEOT" \
| openssl s_client -connect "${domain}:443" -servername "${domain}" 2>&1);

if [[ "${tmp}" = *"-----BEGIN CERTIFICATE-----"* ]]; then
local certText=$(echo "${tmp}" \
certText=$(echo "${tmp}" \
| openssl x509 -text -certopt "no_aux, no_header, no_issuer, no_pubkey, \
no_serial, no_sigdump, no_signame, no_validity, no_version");
echo "Common Name:";