From 498029a13c89b81cf6bdb5dc2708fd852e8c74b5 Mon Sep 17 00:00:00 2001 From: Jose Date: Wed, 5 Feb 2020 07:00:11 -0400 Subject: [PATCH] Code improvements, use awk for exact match --- usr/local/share/bastille/cmd.sh | 2 +- usr/local/share/bastille/console.sh | 2 +- usr/local/share/bastille/cp.sh | 2 +- usr/local/share/bastille/htop.sh | 2 +- usr/local/share/bastille/limits.sh | 2 +- usr/local/share/bastille/pkg.sh | 2 +- usr/local/share/bastille/service.sh | 2 +- usr/local/share/bastille/sysrc.sh | 2 +- usr/local/share/bastille/template.sh | 2 +- usr/local/share/bastille/top.sh | 2 +- usr/local/share/bastille/update.sh | 2 +- usr/local/share/bastille/zfs.sh | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/usr/local/share/bastille/cmd.sh b/usr/local/share/bastille/cmd.sh index 2eb2bc42..8bc3e8d8 100644 --- a/usr/local/share/bastille/cmd.sh +++ b/usr/local/share/bastille/cmd.sh @@ -53,7 +53,7 @@ if [ "${TARGET}" = 'ALL' ]; then JAILS=$(jls name) fi if [ "${TARGET}" != 'ALL' ]; then - JAILS=$(jls name | grep -w "${TARGET}") + JAILS=$(jls name | awk "/^${TARGET}$/") fi for _jail in ${JAILS}; do diff --git a/usr/local/share/bastille/console.sh b/usr/local/share/bastille/console.sh index e80f9f9c..4860e1dd 100644 --- a/usr/local/share/bastille/console.sh +++ b/usr/local/share/bastille/console.sh @@ -54,7 +54,7 @@ if [ "${TARGET}" = 'ALL' ]; then JAILS=$(jls name) fi if [ "${TARGET}" != 'ALL' ]; then - JAILS=$(jls name | grep -w "${TARGET}") + JAILS=$(jls name | awk "/^${TARGET}$/") fi validate_user() { diff --git a/usr/local/share/bastille/cp.sh b/usr/local/share/bastille/cp.sh index 088d5a7f..92681fba 100644 --- a/usr/local/share/bastille/cp.sh +++ b/usr/local/share/bastille/cp.sh @@ -55,7 +55,7 @@ if [ "${TARGET}" = 'ALL' ]; then JAILS=$(jls name) fi if [ "${TARGET}" != 'ALL' ]; then - JAILS=$(jls name | grep -w "${TARGET}") + JAILS=$(jls name | awk "/^${TARGET}$/") fi for _jail in ${JAILS}; do diff --git a/usr/local/share/bastille/htop.sh b/usr/local/share/bastille/htop.sh index a675f38b..0af8f2d5 100644 --- a/usr/local/share/bastille/htop.sh +++ b/usr/local/share/bastille/htop.sh @@ -54,7 +54,7 @@ if [ "${TARGET}" = 'ALL' ]; then JAILS=$(jls name) fi if [ "${TARGET}" != 'ALL' ]; then - JAILS=$(jls name | grep -w "${TARGET}") + JAILS=$(jls name | awk "/^${TARGET}$/") fi for _jail in ${JAILS}; do diff --git a/usr/local/share/bastille/limits.sh b/usr/local/share/bastille/limits.sh index d1bbd692..8667d195 100644 --- a/usr/local/share/bastille/limits.sh +++ b/usr/local/share/bastille/limits.sh @@ -63,7 +63,7 @@ if [ "${TARGET}" = 'ALL' ]; then fi if [ "${TARGET}" != 'ALL' ]; then - JAILS=$(jls name | grep -w "${TARGET}") + JAILS=$(jls name | awk "/^${TARGET}$/") fi for _jail in ${JAILS}; do diff --git a/usr/local/share/bastille/pkg.sh b/usr/local/share/bastille/pkg.sh index 081ee3ff..77479144 100644 --- a/usr/local/share/bastille/pkg.sh +++ b/usr/local/share/bastille/pkg.sh @@ -53,7 +53,7 @@ if [ "${TARGET}" = 'ALL' ]; then JAILS=$(jls name) fi if [ "${TARGET}" != 'ALL' ]; then - JAILS=$(jls name | grep -w "${TARGET}") + JAILS=$(jls name | awk "/^${TARGET}$/") fi for _jail in ${JAILS}; do diff --git a/usr/local/share/bastille/service.sh b/usr/local/share/bastille/service.sh index 17c6578d..f3d99244 100644 --- a/usr/local/share/bastille/service.sh +++ b/usr/local/share/bastille/service.sh @@ -54,7 +54,7 @@ if [ "${TARGET}" = 'ALL' ]; then fi if [ "${TARGET}" != 'ALL' ]; then - JAILS=$(jls name | grep -w "${TARGET}") + JAILS=$(jls name | awk "/^${TARGET}$/") fi for _jail in ${JAILS}; do diff --git a/usr/local/share/bastille/sysrc.sh b/usr/local/share/bastille/sysrc.sh index 317d9580..2f40dad1 100644 --- a/usr/local/share/bastille/sysrc.sh +++ b/usr/local/share/bastille/sysrc.sh @@ -54,7 +54,7 @@ if [ "${TARGET}" = 'ALL' ]; then fi if [ "${TARGET}" != 'ALL' ]; then - JAILS=$(jls name | grep -w "${TARGET}") + JAILS=$(jls name | awk "/^${TARGET}$/") fi for _jail in ${JAILS}; do diff --git a/usr/local/share/bastille/template.sh b/usr/local/share/bastille/template.sh index bcd66f59..b28be81e 100644 --- a/usr/local/share/bastille/template.sh +++ b/usr/local/share/bastille/template.sh @@ -54,7 +54,7 @@ if [ "${TARGET}" = 'ALL' ]; then JAILS=$(jls name) fi if [ "${TARGET}" != 'ALL' ]; then - JAILS=$(jls name | grep -w "${TARGET}") + JAILS=$(jls name | awk "/^${TARGET}$/") fi TEMPLATE="${1}" diff --git a/usr/local/share/bastille/top.sh b/usr/local/share/bastille/top.sh index 9f0cd692..80c601b6 100644 --- a/usr/local/share/bastille/top.sh +++ b/usr/local/share/bastille/top.sh @@ -54,7 +54,7 @@ if [ "${TARGET}" = 'ALL' ]; then fi if [ "${TARGET}" != 'ALL' ]; then - JAILS=$(jls name | grep -w "${TARGET}") + JAILS=$(jls name | awk "/^${TARGET}$/") fi for _jail in ${JAILS}; do diff --git a/usr/local/share/bastille/update.sh b/usr/local/share/bastille/update.sh index f9bd827b..0c93e71f 100644 --- a/usr/local/share/bastille/update.sh +++ b/usr/local/share/bastille/update.sh @@ -57,7 +57,7 @@ fi if [ -d "${bastille_jailsdir}/${TARGET}" ]; then if ! grep -qw ".bastille" "${bastille_jailsdir}/${TARGET}/fstab"; then - if [ "$(jls name | grep -w "${TARGET}")" ]; then + if [ "$(jls name | awk "/^${TARGET}$/")" ]; then # Update a thick container. CURRENT_VERSION=$(/usr/sbin/jexec -l ${TARGET} freebsd-version 2>/dev/null) if [ -z "${CURRENT_VERSION}" ]; then diff --git a/usr/local/share/bastille/zfs.sh b/usr/local/share/bastille/zfs.sh index 32d46363..82f49651 100644 --- a/usr/local/share/bastille/zfs.sh +++ b/usr/local/share/bastille/zfs.sh @@ -98,7 +98,7 @@ if [ "${TARGET}" = 'ALL' ]; then fi if [ "${TARGET}" != 'ALL' ]; then - JAILS=$(jls name | grep -w "${TARGET}") + JAILS=$(jls name | awk "/^${TARGET}$/") fi case "$2" in