changeset 649:4ee9a8042f4a

common.subr: _get_jail_from_path() now just returns when the jail is dying. But it prints the name of the jail if it is yet dying. Real error reporting must not consistently be done in the caller.
author Franz Glasner <fzglas.hg@dom66.de>
date Fri, 27 Sep 2024 21:21:34 +0200
parents cd4aea87dbfa
children 5a367d44b480
files share/local-bsdtools/common.subr
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/share/local-bsdtools/common.subr	Fri Sep 27 20:35:34 2024 +0200
+++ b/share/local-bsdtools/common.subr	Fri Sep 27 21:21:34 2024 +0200
@@ -303,11 +303,12 @@
 #: Search for a running jail where it's "path" points to a given location
 #:
 #: Args:
-#:   $1: the location to search for
+#:   $1 (str): The location to search for.
 #:
 #: Output (stdout):
 #:   The name if the jail with a "path" that is equal to the input param.
 #:   Nothing if a jail is not found.
+#:   The name is written when the jail is running and/or a dying.
 #:
 #: Return:
 #:   0: if a running jail is found
@@ -353,7 +354,8 @@
             while IFS=$'\t' read -r _dying _name _path ; do
                 if [ "${_path}" = "${_location}" ]; then
                     if [ "${_dying}" != "false" ]; then
-                        echo "Jail \`${_name}' is currently dying" 1>&2
+                        # Dying
+                        printf '%s' "${_name}"
                         return 2
                     fi
                     printf '%s' "${_name}"
@@ -368,7 +370,8 @@
             while IFS=' '$'\t' read -r _name _dying _path ; do
                 if [ "${_path}" = "${_location}" ]; then
                     if [ "${_dying}" != "false" ]; then
-                        echo "Jail \`${_name}' is currently dying" 1>&2
+                        # Dying
+                        printf '%s' "${_name}"
                         return 2
                     fi
                     printf '%s' "${_name}"