Skip to content

Commit

Permalink
out of memory warning
Browse files Browse the repository at this point in the history
  • Loading branch information
sinamics committed Jan 16, 2024
1 parent e5c5aa9 commit 917374f
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions install.ztnet/bash/ztnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,19 @@ silent() {
local command="$@"

if [ "$SILENT_MODE" = "Yes" ]; then
# Capture the output and get the exit status
output="$($command 2>&1)"
status=$?
# Check for "heap out of memory" error in the output
if [ $status -ne 0 ] || echo "$output" | grep -q "heap out of memory"; then
# Handle the specific "heap out of memory" error
failure $BASH_LINENO "$command" "$status" "$output"

# Check for general error or specific "heap out of memory" error
if [ $status -ne 0 ]; then
if echo "$output" | grep -q "out of memory"; then
# If "heap out of memory" error is found, change the output message
failure $BASH_LINENO "$command" "$status" "Out of Memory"
else
# For other errors, pass the original output
failure $BASH_LINENO "$command" "$status" "$output"
fi
fi
fi
}
Expand All @@ -241,8 +248,14 @@ verbose() {
status=$?

if [ $status -ne 0 ]; then
# An error occurred
failure $BASH_LINENO "$command" "$status" "$output"
# Check for "heap out of memory" error in the output
if echo "$output" | grep -q "out of memory"; then
# Handle the specific "heap out of memory" error
failure $BASH_LINENO "$command" "$status" "Out of Memory"
else
# Handle other types of errors
failure $BASH_LINENO "$command" "$status" "$output"
fi
fi
}

Expand Down

0 comments on commit 917374f

Please sign in to comment.