IMP(shellcheck): remove $() in if condition (SC2091)

This commit is contained in:
Thibault Ayanides 2020-12-10 08:16:23 +01:00
parent 99ac9339f4
commit 1c56bd9930
2 changed files with 13 additions and 13 deletions

View File

@ -29,7 +29,7 @@ audit() {
ok "Nothing listens on 25 port, probably unix socket configured" ok "Nothing listens on 25 port, probably unix socket configured"
else else
info "Checking $RESULT" info "Checking $RESULT"
if $(grep -q "127.0.0.1" <<<"$RESULT"); then if grep -q "127.0.0.1" <<<"$RESULT"; then
ok "MTA is configured to localhost only" ok "MTA is configured to localhost only"
else else
crit "MTA listens worldwide" crit "MTA listens worldwide"
@ -47,7 +47,7 @@ apply() {
ok "Nothing listens on 25 port, probably unix socket configured" ok "Nothing listens on 25 port, probably unix socket configured"
else else
info "Checking $RESULT" info "Checking $RESULT"
if $(grep -q "127.0.0.1" <<<"$RESULT"); then if grep -q "127.0.0.1" <<<"$RESULT"; then
ok "MTA is configured to localhost only" ok "MTA is configured to localhost only"
else else
warn "MTA listens worldwide, correct this considering your MTA" warn "MTA listens worldwide, correct this considering your MTA"

View File

@ -52,7 +52,7 @@ set_sysctl_param() {
does_pattern_exist_in_dmesg() { does_pattern_exist_in_dmesg() {
local PATTERN=$1 local PATTERN=$1
if $($SUDO_CMD dmesg | grep -qE "$PATTERN"); then if $SUDO_CMD dmesg | grep -qE "$PATTERN"; then
FNRET=0 FNRET=0
else else
FNRET=1 FNRET=1
@ -117,7 +117,7 @@ _does_pattern_exist_in_file() {
debug "Checking if $PATTERN is present in $FILE" debug "Checking if $PATTERN is present in $FILE"
if $SUDO_CMD [ -r "$FILE" ]; then if $SUDO_CMD [ -r "$FILE" ]; then
debug "$SUDO_CMD grep -q $OPTIONS -- '$PATTERN' $FILE" debug "$SUDO_CMD grep -q $OPTIONS -- '$PATTERN' $FILE"
if $($SUDO_CMD grep -q "$OPTIONS" -- "$PATTERN" "$FILE"); then if $SUDO_CMD grep -q "$OPTIONS" -- "$PATTERN" "$FILE"; then
debug "Pattern found in $FILE" debug "Pattern found in $FILE"
FNRET=0 FNRET=0
else else
@ -148,7 +148,7 @@ does_pattern_exist_in_file_multiline() {
debug "Checking if multiline pattern: $PATTERN is present in $FILE" debug "Checking if multiline pattern: $PATTERN is present in $FILE"
if $SUDO_CMD [ -r "$FILE" ]; then if $SUDO_CMD [ -r "$FILE" ]; then
debug "$SUDO_CMD grep -v '^[[:space:]]*#' $FILE | tr '\n' ' ' | grep -Pq -- "$PATTERN"" debug "$SUDO_CMD grep -v '^[[:space:]]*#' $FILE | tr '\n' ' ' | grep -Pq -- "$PATTERN""
if $($SUDO_CMD grep -v '^[[:space:]]*#' "$FILE" | tr '\n' ' ' | grep -Pq -- "$PATTERN"); then if $SUDO_CMD grep -v '^[[:space:]]*#' "$FILE" | tr '\n' ' ' | grep -Pq -- "$PATTERN"; then
debug "Pattern found in $FILE" debug "Pattern found in $FILE"
FNRET=0 FNRET=0
else else
@ -214,7 +214,7 @@ delete_line_in_file() {
does_user_exist() { does_user_exist() {
local USER=$1 local USER=$1
if $(getent passwd "$USER" >/dev/null 2>&1); then if getent passwd "$USER" >/dev/null 2>&1; then
FNRET=0 FNRET=0
else else
FNRET=1 FNRET=1
@ -223,7 +223,7 @@ does_user_exist() {
does_group_exist() { does_group_exist() {
local GROUP=$1 local GROUP=$1
if $(getent group "$GROUP" >/dev/null 2>&1); then if getent group "$GROUP" >/dev/null 2>&1; then
FNRET=0 FNRET=0
else else
FNRET=1 FNRET=1
@ -302,7 +302,7 @@ is_a_partition() {
local PARTITION_NAME=$1 local PARTITION_NAME=$1
FNRET=128 FNRET=128
if $(grep "[[:space:]]$1[[:space:]]" /etc/fstab | grep -vqE "^#"); then if grep "[[:space:]]$1[[:space:]]" /etc/fstab | grep -vqE "^#"; then
debug "$PARTITION found in fstab" debug "$PARTITION found in fstab"
FNRET=0 FNRET=0
else else
@ -314,7 +314,7 @@ is_a_partition() {
# Verify that $1 is mounted at runtime # Verify that $1 is mounted at runtime
is_mounted() { is_mounted() {
local PARTITION_NAME=$1 local PARTITION_NAME=$1
if $(grep -q "[[:space:]]$1[[:space:]]" /proc/mounts); then if grep -q "[[:space:]]$1[[:space:]]" /proc/mounts; then
debug "$PARTITION found in /proc/mounts, it's mounted" debug "$PARTITION found in /proc/mounts, it's mounted"
FNRET=0 FNRET=0
else else
@ -327,12 +327,12 @@ is_mounted() {
has_mount_option() { has_mount_option() {
local PARTITION=$1 local PARTITION=$1
local OPTION=$2 local OPTION=$2
if $(grep "[[:space:]]${PARTITION}[[:space:]]" /etc/fstab | grep -vE "^#" | awk '{print $4}' | grep -q "bind"); then if grep "[[:space:]]${PARTITION}[[:space:]]" /etc/fstab | grep -vE "^#" | awk '{print $4}' | grep -q "bind"; then
local actual_partition="$(grep "[[:space:]]${PARTITION}[[:space:]]" /etc/fstab | grep -vE "^#" | awk '{print $1}')" local actual_partition="$(grep "[[:space:]]${PARTITION}[[:space:]]" /etc/fstab | grep -vE "^#" | awk '{print $1}')"
debug "$PARTITION is a bind mount of $actual_partition" debug "$PARTITION is a bind mount of $actual_partition"
PARTITION="$actual_partition" PARTITION="$actual_partition"
fi fi
if $(grep "[[:space:]]${PARTITION}[[:space:]]" /etc/fstab | grep -vE "^#" | awk '{print $4}' | grep -q "$OPTION"); then if grep "[[:space:]]${PARTITION}[[:space:]]" /etc/fstab | grep -vE "^#" | awk '{print $4}' | grep -q "$OPTION"; then
debug "$OPTION has been detected in fstab for partition $PARTITION" debug "$OPTION has been detected in fstab for partition $PARTITION"
FNRET=0 FNRET=0
else else
@ -345,7 +345,7 @@ has_mount_option() {
has_mounted_option() { has_mounted_option() {
local PARTITION=$1 local PARTITION=$1
local OPTION=$2 local OPTION=$2
if $(grep "[[:space:]]$1[[:space:]]" /proc/mounts | awk '{print $4}' | grep -q "$2"); then if grep "[[:space:]]$1[[:space:]]" /proc/mounts | awk '{print $4}' | grep -q "$2"; then
debug "$OPTION has been detected in /proc/mounts for partition $PARTITION" debug "$OPTION has been detected in /proc/mounts for partition $PARTITION"
FNRET=0 FNRET=0
else else
@ -419,7 +419,7 @@ apt_install() {
is_pkg_installed() { is_pkg_installed() {
PKG_NAME=$1 PKG_NAME=$1
if $(dpkg -s "$PKG_NAME" 2>/dev/null | grep -q '^Status: install '); then if dpkg -s "$PKG_NAME" 2>/dev/null | grep -q '^Status: install '; then
debug "$PKG_NAME is installed" debug "$PKG_NAME is installed"
FNRET=0 FNRET=0
else else