Skip to content

Commit

Permalink
More broken pipe prevention (annoyance, not bugs)
Browse files Browse the repository at this point in the history
  • Loading branch information
mario4tier committed Jun 12, 2024
1 parent 9ca57f9 commit 342da13
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions scripts/common/__globals.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1982,10 +1982,10 @@ get_process_pid() {
# More info: https://github.com/ChainMovers/suibase/issues/79

# shellcheck disable=SC2009
_PID=$(ps x -o pid,comm | grep "$_PROC$" | grep -v -e grep -e $SUIBASE_DAEMON_NAME | head -n 1 | sed -e 's/^[[:space:]]*//' | sed 's/ /\n/g' | head -n 1)
_PID=$(ps x -o pid,comm | grep "$_PROC$" | grep -v -e grep -e $SUIBASE_DAEMON_NAME | { head -n 1; cat >/dev/null 2>&1; } | sed -e 's/^[[:space:]]*//' | sed 's/ /\n/g' | { head -n 1; cat >/dev/null 2>&1; })
else
# shellcheck disable=SC2009
_PID=$(ps x -o pid,cmd 2>/dev/null | grep "$_PROC $_ARGS" | grep -v grep | head -n 1 | sed -e 's/^[[:space:]]*//' | sed 's/ /\n/g' | head -n 1)
_PID=$(ps x -o pid,cmd 2>/dev/null | grep "$_PROC $_ARGS" | grep -v grep | { head -n 1; cat >/dev/null 2>&1; } | sed -e 's/^[[:space:]]*//' | sed 's/ /\n/g' | { head -n 1; cat >/dev/null 2>&1; })
fi

if [ -n "$_PID" ]; then
Expand Down Expand Up @@ -2355,7 +2355,7 @@ add_test_addresses() {
# Set highest address as active. Best-effort... just warn if fails.
local _HIGH_ADDR
local _SET_ACTIVE_SUCCESS=false
_HIGH_ADDR=$($SUI_BIN_ENV "$_SUI_BINARY" client --client.config "$_CLIENT_FILE" addresses | grep -v "activeAddress" | grep "0x" | sort -r | head -n 1)
_HIGH_ADDR=$($SUI_BIN_ENV "$_SUI_BINARY" client --client.config "$_CLIENT_FILE" addresses | grep -v "activeAddress" | grep "0x" | sort -r | { head -n 1; cat >/dev/null 2>&1; })
if [[ "$_HIGH_ADDR" =~ 0x[[:xdigit:]]+ ]]; then
_HIGH_ADDR="${BASH_REMATCH[0]}"

Expand Down Expand Up @@ -2925,7 +2925,7 @@ update_PRECOMP_REMOTE_var() {
fi

# Find the binary asset for that release.
_DOWNLOAD_URL=$(echo "$_OUT" | grep "browser_download_url" | grep "$_DOWNLOAD_SUBSTRING" | grep "$_TAG_NAME" | sort -r | head -1)
_DOWNLOAD_URL=$(echo "$_OUT" | grep "browser_download_url" | grep "$_DOWNLOAD_SUBSTRING" | grep "$_TAG_NAME" | sort -r | { head -n 1; cat >/dev/null 2>&1; })
_DOWNLOAD_URL="${_DOWNLOAD_URL#*\:}" # Remove the ":" and everything before
_DOWNLOAD_URL="${_DOWNLOAD_URL#*\"}" # Remove the first '"' and everything before
_DOWNLOAD_URL="${_DOWNLOAD_URL%\"*}" # Remove the last '"' and everything after
Expand Down
4 changes: 2 additions & 2 deletions scripts/tests/__scripts-lib-after-globals.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ assert_workdir_ok() {
if [ ! "$_RESULT" -eq 0 ]; then
fail "workdir-exec usage should not be an error"
fi
_FIRST_WORD=$(echo "$_HELP" | head -n1 | awk '{print $1;}')
_FIRST_WORD=$(echo "$_HELP" | { head -n 1; cat >/dev/null 2>&1; } | awk '{print $1;}')
# Note: Must use contain because of the ANSI color escape code.
[[ "$_FIRST_WORD" == *"$1"* ]] || fail "usage first word [$_FIRST_WORD] not [$1]"

Expand All @@ -66,7 +66,7 @@ assert_build_ok() {
# Verify that the Sui binary execution is OK.
local _VERSION _FIRST_WORD
_VERSION=$($_SUI_BIN --version)
_FIRST_WORD=$(echo "$_VERSION" | head -n1 | awk '{print $1;}')
_FIRST_WORD=$(echo "$_VERSION" | { head -n 1; cat >/dev/null 2>&1; } | awk '{print $1;}')
[ "$_FIRST_WORD" = "sui" ] || fail "sui --version did not work [$_VERSION]"
if [ "${CFG_default_repo_branch:?}" = "main" ]; then
# "Cutting edge" branch is not precompiled by Mysten Labs.
Expand Down
4 changes: 2 additions & 2 deletions update
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ cd "$SUIBASE_DIR" || {
}

_LOCALNET_CMD_OUTPUT=$("$SUIBASE_DIR/scripts/localnet")
_CUR_VER=$(echo "$_LOCALNET_CMD_OUTPUT" | head -n 1 | sed 's/.*suibase \(.*\)/\1/g')
_CUR_VER=$(echo "$_LOCALNET_CMD_OUTPUT" | { head -n 1; cat >/dev/null 2>&1; } | sed 's/.*suibase \(.*\)/\1/g')

# Check if there are significant local changes. If any, protect the user
# from doing further git operations.
Expand Down Expand Up @@ -46,7 +46,7 @@ if [ "$V1" != "$V2" ]; then
("$SUIBASE_DIR/repair")

_LOCALNET_CMD_OUTPUT=$("$SUIBASE_DIR/scripts/localnet")
_NEW_VER=$(echo "$_LOCALNET_CMD_OUTPUT" | head -n 1 | sed 's/.*suibase \(.*\)/\1/g')
_NEW_VER=$(echo "$_LOCALNET_CMD_OUTPUT" | { head -n 1; cat >/dev/null 2>&1; } | sed 's/.*suibase \(.*\)/\1/g')

if [ -n "$_CUR_VER" ]; then
echo "Old version $_CUR_VER"
Expand Down

0 comments on commit 342da13

Please sign in to comment.