fix: avoid stray `\` warning for grep 3.8+
Only the first `-` in ERE need escaping to ensure it's not a command option for `grep`. The fix also tested on BSD grep 2.6 and works well. More details: https://lists.gnu.org/archive/html/info-gnu/2022-09/msg00001.html > Regular expressions with stray backslashes now cause warnings, as their unspecified behavior can lead to unexpected results. For example, '\a' and 'a' are not always equivalent <https://bugs.gnu.org/39678>.
This commit is contained in:
parent
fc62cfdfd8
commit
5a25d53fba
17
bin/emqx
17
bin/emqx
|
@ -451,7 +451,7 @@ find_emqx_process() {
|
|||
if [ -n "${EMQX_NODE__NAME:-}" ]; then
|
||||
# if node name is provided, filter by node name
|
||||
# shellcheck disable=SC2009
|
||||
ps -ef | $GREP '[e]mqx' | $GREP -v -E '(remsh|nodetool)' | $GREP -E "\s\-s?name\s${EMQX_NODE__NAME}" | $GREP -oE "\-[r]oot ${RUNNER_ROOT_DIR}.*" || true
|
||||
ps -ef | $GREP '[e]mqx' | $GREP -v -E '(remsh|nodetool)' | $GREP -E "\s-s?name\s${EMQX_NODE__NAME}" | $GREP -oE "\-[r]oot ${RUNNER_ROOT_DIR}.*" || true
|
||||
else
|
||||
# shellcheck disable=SC2009
|
||||
ps -ef | $GREP '[e]mqx' | $GREP -v -E '(remsh|nodetool)' | $GREP -oE "\-[r]oot ${RUNNER_ROOT_DIR}.*" || true
|
||||
|
@ -482,7 +482,7 @@ RUNNING_NODES_COUNT="$(echo -e "$PS_LINE" | sed '/^\s*$/d' | wc -l)"
|
|||
|
||||
if [ "$IS_BOOT_COMMAND" = 'yes' ]; then
|
||||
if [ "$RUNNING_NODES_COUNT" -gt 0 ] && [ "$COMMAND" != 'check_config' ]; then
|
||||
running_node_name=$(echo -e "$PS_LINE" | $GREP -oE "\s\-s?name.*" | awk '{print $2}' || true)
|
||||
running_node_name=$(echo -e "$PS_LINE" | $GREP -oE "\s-s?name.*" | awk '{print $2}' || true)
|
||||
if [ -n "$running_node_name" ] && [ "$running_node_name" = "${EMQX_NODE__NAME:-}" ]; then
|
||||
echo "Node ${running_node_name} is already running!"
|
||||
exit 1
|
||||
|
@ -520,10 +520,10 @@ else
|
|||
# would try to stop the new node instead.
|
||||
if [ "$RUNNING_NODES_COUNT" -eq 1 ]; then
|
||||
## only one emqx node is running, get running args from 'ps -ef' output
|
||||
tmp_nodename=$(echo -e "$PS_LINE" | $GREP -oE "\s\-s?name.*" | awk '{print $2}' || true)
|
||||
tmp_cookie=$(echo -e "$PS_LINE" | $GREP -oE "\s\-setcookie.*" | awk '{print $2}' || true)
|
||||
tmp_nodename=$(echo -e "$PS_LINE" | $GREP -oE "\s-s?name.*" | awk '{print $2}' || true)
|
||||
tmp_cookie=$(echo -e "$PS_LINE" | $GREP -oE "\s-setcookie.*" | awk '{print $2}' || true)
|
||||
SSL_DIST_OPTFILE="$(echo -e "$PS_LINE" | $GREP -oE '\-ssl_dist_optfile\s.+\s' | awk '{print $2}' || true)"
|
||||
tmp_ticktime="$(echo -e "$PS_LINE" | $GREP -oE '\s\-kernel\snet_ticktime\s.+\s' | awk '{print $3}' || true)"
|
||||
tmp_ticktime="$(echo -e "$PS_LINE" | $GREP -oE '\s-kernel\snet_ticktime\s.+\s' | awk '{print $3}' || true)"
|
||||
# data_dir is actually not needed, but kept anyway
|
||||
tmp_datadir="$(echo -e "$PS_LINE" | $GREP -oE "\-emqx_data_dir.*" | sed -E 's#.+emqx_data_dir[[:blank:]]##g' | sed -E 's#[[:blank:]]--$##g' || true)"
|
||||
if [ -z "$SSL_DIST_OPTFILE" ]; then
|
||||
|
@ -536,7 +536,7 @@ else
|
|||
else
|
||||
if [ "$RUNNING_NODES_COUNT" -gt 1 ]; then
|
||||
if [ -z "${EMQX_NODE__NAME:-}" ]; then
|
||||
tmp_nodenames=$(echo -e "$PS_LINE" | $GREP -oE "\s\-s?name.*" | awk '{print $2}' | tr '\n' ' ')
|
||||
tmp_nodenames=$(echo -e "$PS_LINE" | $GREP -oE "\s-s?name.*" | awk '{print $2}' | tr '\n' ' ')
|
||||
logerr "More than one EMQX node found running (root dir: ${RUNNER_ROOT_DIR})"
|
||||
logerr "Running nodes: $tmp_nodenames"
|
||||
logerr "Make sure environment variable EMQX_NODE__NAME is set to indicate for which node this command is intended."
|
||||
|
@ -806,6 +806,7 @@ generate_config() {
|
|||
}
|
||||
|
||||
# check if a PID is down
|
||||
# shellcheck disable=SC2317 # call in func `nodetool_shutdown()`
|
||||
is_down() {
|
||||
PID="$1"
|
||||
if ps -p "$PID" >/dev/null; then
|
||||
|
@ -937,7 +938,7 @@ case "$NAME" in
|
|||
esac
|
||||
SHORT_NAME="$(echo "$NAME" | awk -F'@' '{print $1}')"
|
||||
HOST_NAME="$(echo "$NAME" | awk -F'@' '{print $2}')"
|
||||
if ! (echo "$SHORT_NAME" | grep -q '^[0-9A-Za-z_\-]\+$'); then
|
||||
if ! (echo "$SHORT_NAME" | $GREP -q '^[0-9A-Za-z_\-]\+$'); then
|
||||
logerr "Invalid node name, should be of format '^[0-9A-Za-z_-]+$'."
|
||||
exit 1
|
||||
fi
|
||||
|
@ -972,7 +973,7 @@ maybe_warn_default_cookie() {
|
|||
## check if OTP version has mnesia_hook feature; if not, fallback to
|
||||
## using Mnesia DB backend.
|
||||
if [[ "$IS_BOOT_COMMAND" == 'yes' && "$(get_boot_config 'node.db_backend')" == "rlog" ]]; then
|
||||
if ! (echo -e "$COMPATIBILITY_INFO" | grep -q 'MNESIA_OK'); then
|
||||
if ! (echo -e "$COMPATIBILITY_INFO" | $GREP -q 'MNESIA_OK'); then
|
||||
logerr "DB Backend is RLOG, but an incompatible OTP version has been detected. Falling back to using Mnesia DB backend."
|
||||
export EMQX_NODE__DB_BACKEND=mnesia
|
||||
export EMQX_NODE__DB_ROLE=core
|
||||
|
|
|
@ -18,7 +18,7 @@ fi
|
|||
echo "elvis -v: $elvis_version"
|
||||
echo "git diff base: $base"
|
||||
|
||||
if [ ! -f ./elvis ] || [ "$(./elvis -v | grep -oE '[1-9]+\.[0-9]+\.[0-9]+\-emqx-[0-9]+')" != "$elvis_version" ]; then
|
||||
if [ ! -f ./elvis ] || [ "$(./elvis -v | grep -oE '[1-9]+\.[0-9]+\.[0-9]+-emqx-[0-9]+')" != "$elvis_version" ]; then
|
||||
curl --silent --show-error -fLO "https://github.com/emqx/elvis/releases/download/$elvis_version/elvis"
|
||||
chmod +x ./elvis
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue