changeset 637:971ac60a2f94

common.subr: Use LC_ALL=C.UTF-8 where appropriate. This is because JSON is relies on valid UTF-8 content in string values.
author Franz Glasner <fzglas.hg@dom66.de>
date Fri, 27 Sep 2024 13:03:11 +0200
parents 7800bac1fe7e
children 3ac8fec90c96
files share/local-bsdtools/common.subr
diffstat 1 files changed, 8 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/share/local-bsdtools/common.subr	Thu Sep 26 15:21:33 2024 +0200
+++ b/share/local-bsdtools/common.subr	Fri Sep 27 13:03:11 2024 +0200
@@ -235,7 +235,7 @@
 
     if [ -x "${JQ}" ]; then
         /sbin/mount -t zfs -p --libxo=json,no-locale \
-        | LC_ALL=C "${JQ}" -r $'.mount.fstab[] | [.device, .mntpoint, .fstype, .opts, .dump, .pass] | @tsv ' \
+        | LC_ALL=C.UTF-8 "${JQ}" -r $'.mount.fstab[] | [.device, .mntpoint, .fstype, .opts, .dump, .pass] | @tsv ' \
         | {
             while IFS=$'\t' read -r _ds _mount _rest ; do
                 if [ "$_mount" = "$_mountpoint" ]; then
@@ -325,7 +325,7 @@
 
     if [ -x "${JQ}" ]; then
         /usr/sbin/jls --libxo=json,no-locale -d dying name path \
-        | LC_ALL=C "${JQ}" -r $'.["jail-information"].jail[] | [.dying, .name, .path] | @tsv ' \
+        | LC_ALL=C.UTF-8 "${JQ}" -r $'.["jail-information"].jail[] | [.dying, .name, .path] | @tsv ' \
         | { # '
             while IFS=$'\t' read -r _dying _name _path ; do
                 if [ "${_path}" = "${_location}" ]; then
@@ -406,9 +406,9 @@
 
     if [ -x "${JQ}" ]; then
         /sbin/mount -t zfs -p --libxo=json,no-locale \
-        | LC_ALL=C "${JQ}" -r $'.mount.fstab[] | [.device, .mntpoint, .fstype, .opts, .dump, .pass] | @tsv ' \
-        | LC_ALL=C /usr/bin/awk -F $'\\t+' -v OFS=$'\t' -v ds1="${_dsname}" -v ds2="${_dsname}/" $'{ if (($1 == ds1) || (index($1, ds2) == 1)) { print $1, $2, $3, $4, $5, $6; } }' \
-        | LC_ALL=C /usr/bin/sort --field-separator=$'\t' --key=2 ${_opt_reversed}
+        | LC_ALL=C.UTF-8 "${JQ}" -r $'.mount.fstab[] | [.device, .mntpoint, .fstype, .opts, .dump, .pass] | @tsv ' \
+        | LC_ALL=C.UTF-8 /usr/bin/awk -F $'\\t+' -v OFS=$'\t' -v ds1="${_dsname}" -v ds2="${_dsname}/" $'{ if (($1 == ds1) || (index($1, ds2) == 1)) { print $1, $2, $3, $4, $5, $6; } }' \
+        | LC_ALL=C.UTF-8 /usr/bin/sort --field-separator=$'\t' --key=2 ${_opt_reversed}
     else
         # Check for unexpected spaces
         if ! check_for_proper_fstab; then
@@ -487,9 +487,9 @@
     esac
     if [ -x "${JQ}" ]; then
         /sbin/mount -p --libxo=json,no-locale \
-        | LC_ALL=C "${JQ}" -r $'.mount.fstab[] | [.device, .mntpoint, .fstype, .opts, .dump, .pass] | @tsv ' \
-        | LC_ALL=C /usr/bin/awk -F $'\\t+' -v OFS=$'\t' -v mp1="${_mp1}" -v mp2="${_mp2}" $'{ if (($2 == mp1) || (index($2, mp2) == 1)) { print; } }' \
-        | LC_ALL=C /usr/bin/sort --field-separator=$'\t' --key=2 ${_opt_reversed}
+        | LC_ALL=C.UTF-8 "${JQ}" -r $'.mount.fstab[] | [.device, .mntpoint, .fstype, .opts, .dump, .pass] | @tsv ' \
+        | LC_ALL=C.UTF-8 /usr/bin/awk -F $'\\t+' -v OFS=$'\t' -v mp1="${_mp1}" -v mp2="${_mp2}" $'{ if (($2 == mp1) || (index($2, mp2) == 1)) { print; } }' \
+        | LC_ALL=C.UTF-8 /usr/bin/sort --field-separator=$'\t' --key=2 ${_opt_reversed}
     else
         # Check for unexpected spaces
         if ! check_for_proper_fstab; then