From 172a9e5461e8d42aaa327f20437f9a3f104377cd Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Sat, 16 Jan 2021 11:20:29 +0100 Subject: [PATCH] sed/grep no redirect from file --- bashbot.sh | 6 +++--- modules/jsonDB.sh | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bashbot.sh b/bashbot.sh index c7eaa7f..d3d763d 100755 --- a/bashbot.sh +++ b/bashbot.sh @@ -30,7 +30,7 @@ BOTCOMMANDS="-h help init start stop status suspendback resumeback killb # 8 - curl/wget missing # 10 - not bash! # -#### $$VERSION$$ v1.30-dev-24-g2771783 +#### $$VERSION$$ v1.30-dev-31-g161e883 ################################################################## # emmbeded system may claim bash but it is not @@ -102,7 +102,7 @@ setConfigKey() { } getConfigKey() { [[ "$1" =~ ^[-${azAZo9},._]+$ ]] || return 3 - [ -r "${BOTCONFIG}.jssh" ] && sed -n 's/\["'"$1"'"\]\t*"\(.*\)"/\1/p' <"${BOTCONFIG}.jssh" | tail -n 1 + [ -r "${BOTCONFIG}.jssh" ] && sed -n 's/\["'"$1"'"\]\t*"\(.*\)"/\1/p' "${BOTCONFIG}.jssh" | tail -n 1 } # check if $1 seems a valid token # return true if token seems to be valid @@ -192,7 +192,7 @@ case "$1" in ;; "-h"*) LOGO="${BASHBOT_HOME:-.}/doc/bashbot.ascii" { [ -r "${LOGO}" ] && cat "${LOGO}" - sed -nE -e '/(NOT EDIT)|(shellcheck)/d' -e '3,/###/p' <"$0"; } | more + sed -nE -e '/(NOT EDIT)|(shellcheck)/d' -e '3,/###/p' "$0"; } | more exit;; "help") HELP="${BASHBOT_HOME:-.}/README" if [ -n "${INTERACTIVE}" ];then diff --git a/modules/jsonDB.sh b/modules/jsonDB.sh index 108438c..cc19d29 100644 --- a/modules/jsonDB.sh +++ b/modules/jsonDB.sh @@ -5,7 +5,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v1.25-dev-30-gefca2e0 +#### $$VERSION$$ v1.30-dev-31-g161e883 # # source from commands.sh to use jsonDB functions # @@ -132,7 +132,7 @@ if [ "$(LC_ALL=C type -t "flock")" = "file" ]; then [ -z "${DB}" ] && return 1 # start atomic delete here, exclusive max wait 1s { flock -s -w 1 200 - [ -r "${DB}" ] && sed -n 's/\["'"$1"'"\]\t*"\(.*\)"/\1/p' <"${DB}" | tail -n 1 + [ -r "${DB}" ] && sed -n 's/\["'"$1"'"\]\t*"\(.*\)"/\1/p' "${DB}" | tail -n 1 } 200>"${DB}${JSSH_LOCKNAME}" } @@ -298,7 +298,7 @@ jssh_getKeyDB_async() { [[ "$1" =~ ^${JSSH_KEYOK}+$ ]] || return 3 local DB; DB="$(jssh_checkDB "$2")" [ -z "${DB}" ] && return 1 - [ -r "${DB}" ] && sed -n 's/\["'"$1"'"\]\t*"\(.*\)"/\1/p' <"${DB}" | tail -n 1 + [ -r "${DB}" ] && sed -n 's/\["'"$1"'"\]\t*"\(.*\)"/\1/p' "${DB}" | tail -n 1 } jssh_countKeyDB_async() { @@ -313,7 +313,7 @@ jssh_countKeyDB_async() { Array2Json "oldARR" >"${DB}" elif [ -r "${DB}" ]; then # it's append, but last one counts, its a simple DB ... - VAL="$(sed -n 's/\["'"$1"'"\]\t*"\(.*\)"/\1/p' <"${DB}" | tail -n 1)" + VAL="$(sed -n 's/\["'"$1"'"\]\t*"\(.*\)"/\1/p' "${DB}" | tail -n 1)" printf '["%s"]\t"%s"\n' "${1//,/\",\"}" "$((++VAL))" >>"${DB}" fi }