From 6889039d7630b3679e1bbe39bd3c1bd15690e8ea Mon Sep 17 00:00:00 2001 From: Shang Mu Date: Wed, 28 May 2025 13:23:52 -0400 Subject: [PATCH] Fix silent stop on error due to using output redirection together with `set -eu`. Signed-off-by: Shang Mu --- contrib/dockerd-rootless-setuptool.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/contrib/dockerd-rootless-setuptool.sh b/contrib/dockerd-rootless-setuptool.sh index c804a8cc88..1e5f8935c2 100755 --- a/contrib/dockerd-rootless-setuptool.sh +++ b/contrib/dockerd-rootless-setuptool.sh @@ -238,12 +238,13 @@ init() { fi # instructions: validate subuid for current user + error_subid= if command -v "getsubids" > /dev/null 2>&1; then - getsubids "$USERNAME" > /dev/null 2>&1 || getsubids "$(id -u)" > /dev/null 2>&1 + getsubids "$USERNAME" > /dev/null 2>&1 || getsubids "$(id -u)" > /dev/null 2>&1 || error_subid=1 else - grep -q "^$USERNAME_ESCAPED:\|^$(id -u):" /etc/subuid 2> /dev/null + grep -q "^$USERNAME_ESCAPED:\|^$(id -u):" /etc/subuid 2> /dev/null || error_subid=1 fi - if [ $? -ne 0 ]; then + if [ "$error_subid" = "1" ]; then instructions=$( cat <<- EOI ${instructions} @@ -254,12 +255,13 @@ init() { fi # instructions: validate subgid for current user + error_subid= if command -v "getsubids" > /dev/null 2>&1; then - getsubids -g "$USERNAME" > /dev/null 2>&1 || getsubids -g "$(id -u)" > /dev/null 2>&1 + getsubids -g "$USERNAME" > /dev/null 2>&1 || getsubids -g "$(id -u)" > /dev/null 2>&1 || error_subid=1 else - grep -q "^$USERNAME_ESCAPED:\|^$(id -u):" /etc/subgid 2> /dev/null + grep -q "^$USERNAME_ESCAPED:\|^$(id -u):" /etc/subgid 2> /dev/null || error_subid=1 fi - if [ $? -ne 0 ]; then + if [ "$error_subid" = "1" ]; then instructions=$( cat <<- EOI ${instructions}