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