Meta: Avoid grep failures in scripts that include shell_include.sh

In environments without any `SERENITY*` variables, grep returns an exit
status of 1. This patch ensures that the subcommand exits with status 0
regardless of whether grep finds a match. This prevents the script
from bailing out when `set -eo pipefail` is enabled.
This commit is contained in:
Lucas Chollet authored and Sönke Holz committed 2026-03-01 11:49:12 +01:00
1 parent 5d7141dc6a
commit 20c2100676
1 file changed
+2 -2
+2 -2
View File
@@ -14,8 +14,8 @@ die() {
if [ "$(uname -s)" = "SerenityOS" ]; then
SUDO="pls -E"
elif command -v sudo >/dev/null; then
# Preserve all environment variables starting with SERENITY_.
SERENITY_VARS=$(env | cut -d= -f1 | grep '^SERENITY' | tr '\n' ',' | sed 's/,$//')
# Preserve all environment variables starting with SERENITY.
SERENITY_VARS=$(env | cut -d= -f1 | (grep '^SERENITY' || [[ $? -eq 1 ]]) | tr '\n' ',' | sed 's/,$//')
SUDO="sudo --preserve-env=$SERENITY_VARS"
elif command -v doas >/dev/null; then
if [ "$SUDO_UID" = '' ]; then