From 8e2239f6f74c5c610ac4868999650b1a031433f2 Mon Sep 17 00:00:00 2001
From: Dave Cottlehuber <dch@skunkwerks.at>
Date: Fri, 23 Nov 2018 22:59:40 +0000
Subject: [PATCH] BSD grep is stricter about orphan tokens in -E mode

---
 .gitignore     | 1 +
 lib/ioc-cmd    | 4 ++--
 lib/ioc-common | 4 ++--
 lib/ioc-info   | 2 +-
 lib/ioc-zfs    | 6 +++---
 5 files changed, 9 insertions(+), 8 deletions(-)
 create mode 100644 .gitignore

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..3c49ab7
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/*.gz
diff --git a/lib/ioc-cmd b/lib/ioc-cmd
index 9de349d..c366789 100644
--- a/lib/ioc-cmd
+++ b/lib/ioc-cmd
@@ -100,7 +100,7 @@ __parse_cmd () {
                                       _jail_type
                                 export jail_datasets="$(zfs list -d3 -rH -o \
                                        name ${pool}/iocell | egrep -v \
-                                       "jails$|releases$|templates$|download|${pool}/iocell$|*./root")"
+                                       "jails$|releases$|templates$|download|${pool}/iocell$|/root$")"
                             done
                         else
                             export _force=0
@@ -111,7 +111,7 @@ __parse_cmd () {
                                       _jail_type
                                 export jail_datasets="$(zfs list -d3 -rH -o \
                                        name ${pool}/iocell | egrep -v \
-                                       "jails$|releases$|templates$|download|${pool}/iocell$|*./root")"
+                                       "jails$|releases$|templates$|download|${pool}/iocell$|/root$")"
                             done
                         fi
 
diff --git a/lib/ioc-common b/lib/ioc-common
index 156c74d..d4f4d1e 100644
--- a/lib/ioc-common
+++ b/lib/ioc-common
@@ -38,7 +38,7 @@ __set_jail_prop () {
     # Avoid having a stale list when called.
     export jail_datasets="$(zfs list -d3 -rH -o name ${pool}/iocell \
         | egrep -v \
-        "jails$|releases$|templates$|download|${pool}/iocell$|*./root")"
+        "jails$|releases$|templates$|download|${pool}/iocell$|/root$")"
 
     if [ "$3" ] ; then
         _dataset="$3"
@@ -241,7 +241,7 @@ __set_jail_prop () {
                 # We need to ignore a few more datasets here.
                 _jail_datasets="$(zfs list -d3 -rH -o name \
                     ${pool}/iocell | egrep -v \
-                    "jails$|base|releases|templates$|download|${pool}/iocell$|*./root")"
+                    "jails$|base|releases|templates$|download|${pool}/iocell$|/root$")"
 
                 for _fs in ${_jail_datasets} ; do
                     # _jail_fs is actually a dataset, so fulluuid needs to
diff --git a/lib/ioc-info b/lib/ioc-info
index ff3a201..ed356cb 100644
--- a/lib/ioc-info
+++ b/lib/ioc-info
@@ -66,7 +66,7 @@ __find_jail () {
 
     # shellcheck disable=SC2154,SC2155
     export jail_datasets="$(zfs list -d3 -rH -o name "${pool}/iocell" \
-        | egrep -v "jails$|base|releases|templates$|download|${pool}/iocell$|*./root|*./data")"
+        | egrep -v "jails$|base|releases|templates$|download|${pool}/iocell$|/root$|/data$")"
 
     if [ "${_name}" = "ALL" ] ; then
         for _jail in ${jail_datasets} ; do
diff --git a/lib/ioc-zfs b/lib/ioc-zfs
index 7894dda..7c6051f 100644
--- a/lib/ioc-zfs
+++ b/lib/ioc-zfs
@@ -249,7 +249,7 @@ __migrate_basejail () {
     _release="$2"
     _orelease="${_release}"
     _grepstring="jails$|base|releases|templates$|download|${pool}/iocell$"
-    _grepstring="${_grepstring}|*./data|*./root"
+    _grepstring="${_grepstring}|/data$|/root$"
     _bfs_list="bin
                boot
                lib
@@ -980,7 +980,7 @@ __check_filesystems () {
     # shellcheck disable=SC2155
     export jail_datasets=$(zfs list -d3 -rH -o name "${pool}/iocell" \
         | egrep -v \
-        "jails$|releases$|templates$|download|${pool}/iocell$|*./root")
+        "jails$|releases$|templates$|download|${pool}/iocell$|/root$")
 
     # Checks to see if the user changed the altroot and modify ioc-globals
     # If the user decided to unset their altroot, they need to run again as
@@ -1041,7 +1041,7 @@ __check_children () {
     _fulluuid="$1"
     _dataset="$2"
     _grepstring="jails$|base|releases|templates$|download|${pool}/iocell$"
-    _grepstring="${_grepstring}|*./data"
+    _grepstring="${_grepstring}|/data$"
     _jail_datasets=$(zfs list -d3 -rH -o name "${pool}/iocell" \
         | egrep -v "${_grepstring}")
 
