Thread (1 message) 1 message, 1 author, 2018-03-28

Re: [PATCH v2] test_must_be_empty: simplify file existence check

From: Junio C Hamano <hidden>
Date: 2018-03-28 05:20:12

Junio C Hamano [off-list ref] writes:
quoted
 test_must_be_empty () {
-	if ! test -f "$1"
-	then
-		echo "'$1' is missing"
-		return 1
-	elif test -s "$1"
+	test_path_is_file "$1" &&
+	if test -s "$1"
 	then
 		echo "'$1' is not empty, it contains:"
 		cat "$1"
"Just call it" is fine as an idea but

	A &&
	if B
	then
		...
	fi

is somewhat questionable.  Shouldn't we make it

	if A && B
	then
		...
	fi

instead?
Nah, you want to treat A's success as a condition *not* to enter the
"then" clause in this case, so my rewrite is bogus.  SOrry for the
noise.


Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help