Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [PATCH 3/3] Remove stray error message from sed

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:48:53

Ramkumar Ramachandra [off-list ref] writes:
When --continue is invoked without any changes, the following stray
error message appears- sed: can't read $dotest/final-commit: No such
file or directory. Remove this by making sure that the file actually
exists.
quoted hunk
Signed-off-by: Ramkumar Ramachandra <redacted>
---
 git-am.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/git-am.sh b/git-am.sh
index 04f02a8..e61f47a 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -693,7 +693,7 @@ do
 	else
 	    action=yes
 	fi
-	FIRSTLINE=$(sed 1q "$dotest/final-commit")
+	test -e "$dotest/final-commit" && FIRSTLINE=$(sed 1q "$dotest/final-commit")
This will let the command follow the same codepath as before but the
change in behaviour is that it does not reset FIRSTLINE to an empty
string.  Does this difference affect what the user sees after this part of
the code?

I would generally prefer to use "test -f" not "-e" (simply because it came
later and I am an old-timer), but if you want to use something newer than
"test -f", it might be worth using "test -r" instead, as readability (not
existence) is what you are after anyway.
 
 	if test $action = skip
 	then
-- 
1.7.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help