changeset 533:07071afd9ae5

Reset some variables in the process environment at loading time: GREP_OPTIONS and PATH_FSTAB. LC_ALL (and LANG and friends) are left alone currently.
author Franz Glasner <fzglas.hg@dom66.de>
date Thu, 05 Sep 2024 22:06:51 +0200
parents c615279bb797
children 46c4798b9b31
files sbin/fzfs share/local-bsdtools/common.subr
diffstat 2 files changed, 19 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/sbin/fzfs	Thu Sep 05 04:05:33 2024 +0200
+++ b/sbin/fzfs	Thu Sep 05 22:06:51 2024 +0200
@@ -322,7 +322,7 @@
           done
     else
         /sbin/mount -t zfs -p \
-        | LC_ALL=C GREP_OPTIONS="" /usr/bin/egrep "^${_dsname}(/|\s)" \
+        | LC_ALL=C /usr/bin/egrep "^${_dsname}(/|\s)" \
         | LC_ALL=C /usr/bin/sort -n -r \
         | while IFS=' '$'\t' read -r _name _mp _rest ; do
             if checkyes _opt_dry_run ; then
--- a/share/local-bsdtools/common.subr	Thu Sep 05 04:05:33 2024 +0200
+++ b/share/local-bsdtools/common.subr	Thu Sep 05 22:06:51 2024 +0200
@@ -438,9 +438,25 @@
     _strict="${2-}"
     if checkyes _strict; then
         # Oracle docs
-        printf "%s" "$1" | LC_ALL=C GREP_OPTIONS="" /usr/bin/egrep -q '^[A-Za-z][-A-Za-z0-9_.]*(/[A-Za-z0-9][-A-Za-z0-9:_.]*)*(@[A-Za-z0-9][-A-Za-z0-9:_.]*)?$'
+        printf "%s" "$1" | LC_ALL=C /usr/bin/egrep -q '^[A-Za-z][-A-Za-z0-9_.]*(/[A-Za-z0-9][-A-Za-z0-9:_.]*)*(@[A-Za-z0-9][-A-Za-z0-9:_.]*)?$'
     else
         # OpenZFS
-        printf "%s" "$1" | LC_ALL=C GREP_OPTIONS="" /usr/bin/egrep -q '^[A-Za-z][-A-Za-z0-9:_. ]*(/[-A-Za-z0-9:_. ]+)*(@[-A-Za-z0-9:_. ]+)?$'
+        printf "%s" "$1" | LC_ALL=C /usr/bin/egrep -q '^[A-Za-z][-A-Za-z0-9:_. ]*(/[-A-Za-z0-9:_. ]+)*(@[-A-Za-z0-9:_. ]+)?$'
     fi
 }
+
+
+#:
+#: Clean the current process environment somewhat
+#:
+reset_environment() {
+    unset PATH_FSTAB
+    unset GREP_OPTIONS
+
+    # XXX: should we do this
+    # export LC_ALL=C
+}
+
+
+# Automatically reset the environment
+reset_environment