"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Christian Weisgerber <naddy@mips.inka.de>
Subject:
regression/cmdline/diff.sh: portability fix
To:
gameoftrees@openbsd.org
Date:
Tue, 17 Jan 2023 22:32:51 +0100

Download raw body.

Thread
The typeset shell builtin is a ksh(1) feature.  It is not available
in a pure POSIX sh(1).  We can use printf(1) to portably perform
the same truncation and padding of a string.

ok?

diff /home/naddy/got
commit - f4e8c21cb2dc6a468bae32a4dcf3a9e18f269527
path + /home/naddy/got
blob - 34b8116a11c50dad2f634dc6fe4dcea09570a334
file + regress/cmdline/diff.sh
--- regress/cmdline/diff.sh
+++ regress/cmdline/diff.sh
@@ -1762,10 +1762,8 @@ EOF
 		return 1
 	fi
 
-	typeset -L10 short_alpha_id
-	typeset -L10 short_alpha_new_id
-	short_alpha_id=$alpha_blobid
-	short_alpha_new_id=$alpha_new_blobid
+	short_alpha_id=$(printf '%-10.10s' $alpha_blobid)
+	short_alpha_new_id=$(printf '%-10.10s' $alpha_new_blobid)
 	cat <<EOF >$testroot/stdout.expected
 diffstat $alpha_blobid $alpha_new_blobid
  M  $short_alpha_id -> $short_alpha_new_id  |  1+  1-
-- 
Christian "naddy" Weisgerber                          naddy@mips.inka.de