On Wed, Dec 04, 2024 at 06:47:58PM +0000, Mark Hindley wrote:
> On Wed, Dec 04, 2024 at 06:10:23PM +0000, Mark Hindley wrote:
> > I think using awk might work well here. Suggested patch attached.
> 
> Or not, apparently RS='\0' is not portable.

Well, I have a nagging feeling that I'm missing something much simpler,
but if you don't mind relying on perl (ucfq is already written in perl),
then I think this works:

diff --git a/ucf b/ucf
index b627038..8f5d358 100755
--- a/ucf
+++ b/ucf
@@ -5,7 +5,6 @@ set -e
 
 # Sanitise environment
 while read -r env ; do
-    env="${env%%=*}"
     case "$env" in
        PATH|PWD|TERM) ;;
        DEB_*|DEBIAN_*|DEBCONF_*) ;;
@@ -13,7 +12,7 @@ while read -r env ; do
        *) unset "$env" ;;
     esac
 done<<EOF
-$(env)
+$(env -0 | perl -lp0e 's/=.*//s')
 EOF
 
 # set the version and revision
diff --git a/ucfr b/ucfr
index f71f572..c3d8892 100755
--- a/ucfr
+++ b/ucfr
@@ -5,14 +5,13 @@ set -e
 
 # Sanitise environment
 while read -r env ; do
-    env="${env%%=*}"
     case "$env" in
        PATH|PWD|TERM) ;;
        UCF_*) ;;
        *) unset "$env" ;;
     esac
 done<<EOF
-$(env)
+$(env -0 | perl -lp0e 's/=.*//s')
 EOF
 
 # set the version and revision

-- 
Colin Watson (he/him)                              [[email protected]]

Reply via email to