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

From:
Omar Polo <op@omarpolo.com>
Subject:
Re: regress for new got log -d
To:
Mark Jamsek <mark@jamsek.com>
Cc:
Game of Trees <gameoftrees@openbsd.org>
Date:
Sat, 07 Jan 2023 14:21:18 +0100

Download raw body.

Thread
On 2023/01/07 23:03:53 +1100, Mark Jamsek <mark@jamsek.com> wrote:
> +	echo "modified\nalpha." > $testroot/wt/alpha

I'm not sure about the portability of using \n with echo.  The ksh(1)
builtin (in non-POSIX mode) respects it, /bin/echo doesn't

	% echo 'foo\nbar'
	foo
	bar
	% /bin/echo 'foo\nbar'
	foo\nbar

it's not too important since we're already using non-posix features
(like `local'), but it's also the only place passing \n to echo
(according to grep, could have missed something) and easy to fix.

ok to switch to printf and heredoc?

diff /home/op/w/got
commit - 8f4e3da96c5f4996c58dc6276417edf32c9589aa
path + /home/op/w/got
blob - 36c40d891f80c07c830e944e477fd259958d981e
file + regress/cmdline/log.sh
--- regress/cmdline/log.sh
+++ regress/cmdline/log.sh
@@ -859,7 +859,7 @@ test_log_diffstat() {
 		return 1
 	fi
 
-	echo "modified\nalpha." > $testroot/wt/alpha
+	printf "modified\nalpha.\n" > $testroot/wt/alpha
 	(cd $testroot/wt && got commit -m 'log_diffstat mod file' > /dev/null)
 
 	(cd $testroot/wt && got rm beta >/dev/null)
@@ -873,23 +873,25 @@ test_log_diffstat() {
 	(cd $testroot/wt && got log -d | grep -A2 '^ [MDmA]' | sed '/^--/d' > \
 	    $testroot/stdout)
 
-	echo " A  new  |  1+  0-" > $testroot/stdout.expected
-	echo "\n1 file changed, 1 insertions(+), 0 deletions(-)" >> \
-	    $testroot/stdout.expected
-	echo " D  beta          |  0+  1-" >> $testroot/stdout.expected
-	echo " m  epsilon/zeta  |  0+  0-" >> $testroot/stdout.expected
-	echo "\n2 files changed, 0 insertions(+), 1 deletions(-)" >> \
-	    $testroot/stdout.expected
-	echo " M  alpha  |  2+  1-" >> $testroot/stdout.expected
-	echo "\n1 file changed, 2 insertions(+), 1 deletions(-)" >> \
-	    $testroot/stdout.expected
-	echo " A  alpha         |  1+  0-" >> $testroot/stdout.expected
-	echo " A  beta          |  1+  0-" >> $testroot/stdout.expected
-	echo " A  epsilon/zeta  |  1+  0-" >> $testroot/stdout.expected
-	echo " A  gamma/delta   |  1+  0-" >> $testroot/stdout.expected
-	echo "\n4 files changed, 4 insertions(+), 0 deletions(-)" >> \
-	    $testroot/stdout.expected
+	cat <<EOF >$testroot/stdout.expected
+ A  new  |  1+  0-
 
+1 file changed, 1 insertions(+), 0 deletions(-)
+ D  beta          |  0+  1-
+ m  epsilon/zeta  |  0+  0-
+
+2 files changed, 0 insertions(+), 1 deletions(-)
+ M  alpha  |  2+  1-
+
+1 file changed, 2 insertions(+), 1 deletions(-)
+ A  alpha         |  1+  0-
+ A  beta          |  1+  0-
+ A  epsilon/zeta  |  1+  0-
+ A  gamma/delta   |  1+  0-
+
+4 files changed, 4 insertions(+), 0 deletions(-)
+EOF
+
 	cmp -s $testroot/stdout.expected $testroot/stdout
 	ret=$?
 	if [ $ret -ne 0 ]; then