From da9601225f52d0409b0a214966711579cbbdc392 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Sun, 5 Dec 2021 23:31:11 -0500 Subject: tools: apply various shellcheck recommendations Signed-off-by: Quentin Young --- tools/frrcommon.sh.in | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'tools') diff --git a/tools/frrcommon.sh.in b/tools/frrcommon.sh.in index a610e56d3..c168edc50 100755 --- a/tools/frrcommon.sh.in +++ b/tools/frrcommon.sh.in @@ -52,7 +52,7 @@ is_user_root () { debug() { [ -n "$watchfrr_debug" ] || return 0 - printf '%s %s(%s):' "`date +%Y-%m-%dT%H:%M:%S.%N`" "$0" $$ >&2 + printf '%s %s(%s):' "$(date +%Y-%m-%dT%H:%M:%S.%N)" "$0" $$ >&2 # this is to show how arguments are split regarding whitespace & co. # (e.g. for use with `debug "message" "$@"`) while [ $# -gt 0 ]; do @@ -78,8 +78,8 @@ vtysh_b () { return 0 fi - cmd="$VTYSH `echo $nsopt` -b" - [ -n "$1" ] && cmd+=" -d $1" + cmd="$VTYSH $nsopt -b" + [ -n "$1" ] && cmd="${cmd} -d $1" log_success_msg "Sending config with '$cmd'" eval "$cmd" @@ -168,7 +168,7 @@ daemon_start() { daemon_inst "$1" - ulimit -n $MAX_FDS > /dev/null 2> /dev/null + [ "$MAX_FDS" != "" ] && ulimit -n "$MAX_FDS" > /dev/null 2> /dev/null daemon_prep "$daemon" "$inst" || return 1 if test ! -d "$V_PATH"; then mkdir -p "$V_PATH" @@ -208,7 +208,7 @@ daemon_stop() { [ -r "$pidfile" ] || fail="pid file not found" $all && [ -n "$fail" ] && return 0 - [ -z "$fail" ] && pid="`cat \"$pidfile\"`" + [ -z "$fail" ] && pid="$(cat \"$pidfile\")" [ -z "$fail" -a -z "$pid" ] && fail="pid file is empty" [ -n "$fail" ] || kill -0 "$pid" 2>/dev/null || fail="pid $pid not running" @@ -242,7 +242,7 @@ daemon_status() { pidfile="$V_PATH/$daemon${inst:+-$inst}.pid" [ -r "$pidfile" ] || return 3 - pid="`cat \"$pidfile\"`" + pid="$(cat \"$pidfile\")" [ -z "$pid" ] && return 1 kill -0 "$pid" 2>/dev/null || return 1 return 0 @@ -366,7 +366,7 @@ frrcommon_main() { cmd="$1" shift - if [ "$1" = "all" -o -z "$1" ]; then + if [ "$1" = "all" ] || [ -z "$1" ]; then case "$cmd" in start) all_start;; stop) all_stop;; -- cgit v1.2.3