From 0c75b5fb66c0b52493aeb53479e5ce3c5459fd24 Mon Sep 17 00:00:00 2001 From: James Tomasino Date: Tue, 30 Apr 2019 17:24:01 -0400 Subject: [PATCH] linting fixes --- bin/jailbreak | 2 +- bin/log | 2 +- bin/mvship | 8 ++++---- bin/newfortune | 2 +- bin/rmship | 6 +++--- bin/user | 4 ++-- completion/log.d | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/bin/jailbreak b/bin/jailbreak index fb9343e..2cc0400 100755 --- a/bin/jailbreak +++ b/bin/jailbreak @@ -8,7 +8,7 @@ run_user=$(id -u) if [ "$run_user" -eq 0 ]; then r="$(/sbin/iptables -L f2b-sshd -n | grep REJECT)" - if [ ! -z "$r" ]; then + if [ -n "$r" ]; then printf "%s" "$r" | awk '{print $4}' | xargs /usr/bin/fail2ban-client set sshd unbanip fi else diff --git a/bin/log b/bin/log index a3fa100..069872b 100755 --- a/bin/log +++ b/bin/log @@ -256,7 +256,7 @@ main() { fi # new message - if [ ! -z "$arg_new" ]; then + if [ -n "$arg_new" ]; then if [ "$numships" -eq 0 ]; then printf "No registered ships found in system.\\n" elif [ "$numships" -eq 1 ]; then diff --git a/bin/mvship b/bin/mvship index 7c29a58..b590311 100755 --- a/bin/mvship +++ b/bin/mvship @@ -6,13 +6,13 @@ if [ "$run_user" -eq 0 ]; then s="$2" newship="$3" - if [ ! -z "$n" ]; then + if [ -n "$n" ]; then user_exists=$(id -u "${n}" 2> /dev/null) - if [ ! -z "${user_exists}" ]; then - if [ ! -z "${s}" ]; then + if [ -n "${user_exists}" ]; then + if [ -n "${s}" ]; then path="/var/gopher/${s}" if [ -d "$path" ]; then - if [ ! -z "${newship}" ]; then + if [ -n "${newship}" ]; then newpath="/var/gopher/${newship}" ship_exists=$(find /var/gopher -maxdepth 1 -iname "$newship") if [ -z "$ship_exists" ]; then diff --git a/bin/newfortune b/bin/newfortune index 3bb4ed7..fd6dc43 100755 --- a/bin/newfortune +++ b/bin/newfortune @@ -1,5 +1,5 @@ #!/bin/sh -if [ ! -z "$1" ]; then +if [ -n "$1" ]; then fort="$*" printf "%s\\n%%\\n" "$fort" >> /usr/share/games/fortunes/cosmic fi diff --git a/bin/rmship b/bin/rmship index 985346d..71c7819 100755 --- a/bin/rmship +++ b/bin/rmship @@ -4,10 +4,10 @@ run_user=$(id -u) if [ "$run_user" -eq 0 ]; then n="$1" s="$2" - if [ ! -z "$n" ]; then + if [ -n "$n" ]; then user_exists=$(id -u "${n}" 2> /dev/null) - if [ ! -z "${user_exists}" ]; then - if [ ! -z "${s}" ]; then + if [ -n "${user_exists}" ]; then + if [ -n "${s}" ]; then path="/var/gopher/${s}" if [ -d "$path" ]; then printf "Removing ship '%s' for user '%s'\\n" "${s}" "${n}" diff --git a/bin/user b/bin/user index 7639f8f..66f6f71 100755 --- a/bin/user +++ b/bin/user @@ -4,7 +4,7 @@ run_user=$(id -u) if [ "$run_user" -eq 0 ]; then n="$1" k="$2" - if [ ! -z "$n" ]; then + if [ -n "$n" ]; then user_exists=$(id -u "${n}" 2> /dev/null) if [ -z "${user_exists}" ]; then printf "Adding new user %s\\n" "${n}" @@ -13,7 +13,7 @@ if [ "$run_user" -eq 0 ]; then useradd -m -G users,www-data -p "$pwcrypt" -s /bin/bash "${n}" || exit 1 sed -e "s/USERNAME/${n}/g" -e "s/PASSWORD/${newpw}/" /etc/templates/welcomemail.tmpl | sendmail "${n}" fi - if [ ! -z "${k}" ]; then + if [ -n "${k}" ]; then printf "%s\\n" "${k}" >> "/home/${n}/.ssh/authorized_keys" else ${EDITOR:-vim} "/home/${n}/.ssh/authorized_keys" diff --git a/completion/log.d b/completion/log.d index 29f811a..6244ae8 100755 --- a/completion/log.d +++ b/completion/log.d @@ -5,7 +5,7 @@ _log() { cur=${COMP_WORDS[COMP_CWORD]} local helplist helplist=$(log -z) - COMPREPLY=( $( compgen -W "$helplist" -- "$cur" ) ) + mapfile -t COMPREPLY < <( compgen -W "$helplist" -- "$cur" ) } # Detect if current shell is ZSH, and if so, load this file in bash