Skip to content

Commit

Permalink
Remove the if statement
Browse files Browse the repository at this point in the history
  • Loading branch information
jiahuili430 committed Apr 10, 2023
1 parent 6370454 commit 263cfcf
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions rel/overlay/bin/remsh
Expand Up @@ -49,12 +49,7 @@ NODE="${NODE:-$DEFAULT_NODE}"

# If present, extract cookie from ERL_FLAGS
# This is used by the CouchDB Dockerfile and Helm chart
if [[ ${ERL_FLAGS} =~ .*[\'\"].*[\'\"].* ]]; then
COOKIE=$(echo "$ERL_FLAGS" | sed 's/.*setcookie *\(['\''"]\)\(.*\)\1.*$/\2/')
else
COOKIE=$(echo "$ERL_FLAGS" | sed 's/^.*setcookie *\([^ ][^ ]*\).*$/\1/')
fi

COOKIE=$(echo "$ERL_FLAGS" | sed 's/^.*setcookie[ ]*\(['\''"]\)*\([^'\''"]*\)\1*.*$/\2/')
if test -f "$ARGS_FILE"; then
# else attempt to extract from vm.args
ARGS_FILE_COOKIE=$(awk '$1=="-setcookie"{st=index($0," "); print substr($0,st+1)}' "$ARGS_FILE" | tr -d \" | tr -d \')
Expand Down Expand Up @@ -116,11 +111,7 @@ fi

# If present, strip -name or -setcookie from ERL_FLAGS
# to avoid conflicts with the cli parameters
if [[ ${ERL_FLAGS} =~ .*[\'\"].*[\'\"].* ]]; then
ERL_FLAGS_CLEAN=$(echo "$ERL_FLAGS" | sed 's/-setcookie *\(['\''"]\)\(.*\)\1//g;s/-name \([^ ][^ ]*\)//g')
else
ERL_FLAGS_CLEAN=$(echo "$ERL_FLAGS" | sed 's/-setcookie *\([^ ][^ ]*\)//g;s/-name \([^ ][^ ]*\)//g')
fi
ERL_FLAGS_CLEAN=$(echo "$ERL_FLAGS" | sed 's/-setcookie[ ]*\(['\''"]\)*\([^'\''"]*\)\1*//;s/-name \([^ ][^ ]*\)//')

if [ -z "${COOKIE}" ]; then
echo "No Erlang cookie could be found, please specify with -c" >&2
Expand Down

0 comments on commit 263cfcf

Please sign in to comment.