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

From:
Stefan Sperling <stsp@stsp.name>
Subject:
Re: regress: Replace sed -i with ed for portability
To:
Omar Polo <op@omarpolo.com>
Cc:
Christian Weisgerber <naddy@mips.inka.de>, gameoftrees@openbsd.org
Date:
Sun, 5 Mar 2023 09:54:20 +0100

Download raw body.

Thread
On Sun, Mar 05, 2023 at 09:10:47AM +0100, Omar Polo wrote:
> > Testing this has turned up an oddity: test_commit_prepared_logmsg()
> > in commit.sh produces a script that performs s/foo/bar/ on a file,
> > but that file doesn't contain the string "foo", so no replacement
> > happens.  Unlike sed(1), ed(1) treats this as an error.  What is
> > that part of the test supposed to accomplish?
> 
> The "editor" script shouldn't do anything, it's a test to see if 'got
> commit' uses the log message prepared in $testroot/logmsg if I'm
> reading this correctly.  it doesn't need sed at all, just a no-op
> script.

Ah, indeed. When I wrote my response I misread what this is supposed to do.

> if this is too cryptic we can replace it with an "exec true"
> or something along those lines:

I agree, this is more clear.

> diff /home/op/w/got
> commit - b43e02dae2f94bde4c5ea9a51f71720f7713019e
> path + /home/op/w/got
> blob - 53011f6f6351ec5e36a888fac308c8d4f0f0002e
> file + regress/cmdline/commit.sh
> --- regress/cmdline/commit.sh
> +++ regress/cmdline/commit.sh
> @@ -1589,10 +1589,8 @@ test_commit_prepared_logmsg() {
>  
>  	echo 'test commit_prepared_logmsg' > $testroot/logmsg
>  
> -	cat > $testroot/editor.sh <<EOF
> -#!/bin/sh
> -sed -i 's/foo/bar/' "\$1"
> -EOF
> +	# a no-op editor script
> +	> $testroot/editor.sh
>  	chmod +x $testroot/editor.sh
>  
>  	(cd $testroot/wt && env VISUAL="$testroot/editor.sh" \