git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/4] t9810: Do not use sed -i

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 1, 2013, 22:12 UTC
Message-ID
<7v38yk8sdj.fsf@alter.siamese.dyndns.org>
In-Reply-To
<201301012240.37769.tboegi@web.de>
Torsten Bögershausen <tboegi@web.de> writes:
Show 23 quoted lines
> sed -i is not portable on all systems.
> Use sed with different input and output files.
> Utilize a tmp file whenever needed
>
> Signed-off-by: Torsten Bögershausen <tboegi@web.de>
> ---
>  t/t9810-git-p4-rcs.sh | 24 ++++++++++++++----------
>  1 file changed, 14 insertions(+), 10 deletions(-)
>
> diff --git a/t/t9810-git-p4-rcs.sh b/t/t9810-git-p4-rcs.sh
> index 0c2fc3e..5bf9291 100755
> --- a/t/t9810-git-p4-rcs.sh
> +++ b/t/t9810-git-p4-rcs.sh
> @@ -26,10 +26,8 @@ test_expect_success 'init depot' '
>  		line7
>  		line8
>  		EOF
> -		cp filek fileko &&
> -		sed -i "s/Revision/Revision: do not scrub me/" fileko
> -		cp fileko file_text &&
> -		sed -i "s/Id/Id: do not scrub me/" file_text
> +		sed <filek "s/Revision/Revision: do not scrub me/" >fileko
> +		sed <fileko "s/Id/Id: do not scrub me/" >file_text

Making it shorter and more correct ;-), which is good, but you are losing the && chaining. Also it is more customary to have redirection at the end, unless it is to redirect a numbered file descriptor (e.g. "echo >&2 error message"). I.e.

	sed "s/Revision/Revision: do not scrub me/" <filek >fileko &&
	sed "s/Id/Id: do not scrub me/" <fileko >file_text
Previous: Torsten Bögershausen
Message 2 of 2 in “t9810: Do not use sed -i”
  1. 2/4 t9810: Do not use sed -iTorsten Bögershausen, Jan 1, 2013
  2. Junio C HamanoJan 1, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.