Download raw body.
regression/cmdline/diff.sh: portability fix
On 23-01-17 11:24PM, Omar Polo wrote: > On 17 January 2023 23:00:15 CET, Omar Polo <op@omarpolo.com> wrote: > >On 2023/01/17 22:32:51 +0100, Christian Weisgerber <naddy@mips.inka.de> wrote: > >> 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? > > > >sure, ok op@. IMHO printf(1) is even more clear than typeset here. > >It's also the only usage of typeset in the regress test. > > > >> 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- > > > > > > actually I think it could even be simplified down to printf '%.10s' since the blobid is guaranteed to be longer than 10 chars and no padding can occur. yes, that's better! ok. I think I just used typeset out of habit -- Mark Jamsek <fnc.bsdbox.org> GPG: F2FF 13DE 6A06 C471 CA80 E6E2 2930 DC66 86EE CF68
regression/cmdline/diff.sh: portability fix