diff sbin/fzfs @ 561:d173161a3a0f

FIX: SC2295: expansions inside ${..} need to be quoted separately, otherwise they will match as a pattern. All our prefixes should be without shell pattern matching (?, *, [ et al.).
author Franz Glasner <fzglas.hg@dom66.de>
date Wed, 11 Sep 2024 18:19:41 +0200
parents 847ae246f3cc
children 5eed2968e671
line wrap: on
line diff
--- a/sbin/fzfs	Wed Sep 11 16:49:17 2024 +0200
+++ b/sbin/fzfs	Wed Sep 11 18:19:41 2024 +0200
@@ -176,7 +176,7 @@
                         _relative_mp=""
                         _real_mp="${_mountpoint}"
                     else
-                        _relative_mp="${_mp#${_rootds_mountpoint_prefix}}"
+                        _relative_mp="${_mp#"${_rootds_mountpoint_prefix}"}"
                         # Eventually remove a trailing slash
                         _relative_mp="${_relative_mp%/}"
                         if [ -z "${_relative_mp}" ]; then
@@ -436,7 +436,7 @@
         IFS=$' \t\n'
 
         # Determine the relative name of the dataset
-        _ds_relname="${_ds#${_ds_source_base}}"
+        _ds_relname="${_ds#"${_ds_source_base}"}"
 
         _ds_canmount=$(zfs get -H -o value canmount "${_ds}")
 
@@ -567,7 +567,7 @@
     _idx=1
     while farray_tryget _ds _ds_tree ${_idx}; do
         # Determine the relative name of the dataset
-        _ds_relname="${_ds#${_ds_source_base}}"
+        _ds_relname="${_ds#"${_ds_source_base}"}"
 
         # Need to determine in *every* case (local, default, received, ...)
         _ds_canmount="$(zfs get -H -o value canmount "${_ds}")"
@@ -631,7 +631,7 @@
     _idx=1
     while farray_tryget _ds _ds_tree ${_idx}; do
         # Determine the relative name of the dataset
-        _ds_relname="${_ds#${_ds_source_base}}"
+        _ds_relname="${_ds#"${_ds_source_base}"}"
 
         # Need to determine in *every* case (default, local, received, ...)
         _ds_canmount="$(zfs get -H -o value canmount "${_ds}")"
@@ -735,7 +735,7 @@
     | {
         while IFS=$'\t' read -r _current_name _current_type ; do
             # Determine the relative name of the dataset
-            _relative_name="${_current_name#${_source_name}}"
+            _relative_name="${_current_name#"${_source_name}"}"
             _relative_name="${_relative_name%@*}"
             if [ "${_current_type}" != "filesystem" ]; then
                 echo "ERROR: Got a snapshot but expected a filesystem" 1>&2