From 7389c8a3e9d92a11d6d90d70240e45395c62fbd0 Mon Sep 17 00:00:00 2001 From: Guus der Kinderen Date: Sun, 6 Nov 2022 09:33:59 +0100 Subject: [PATCH] for #1235: Remove redundant braces in if-expression As per @horazont's feedback: > You do not need () around the command in an if. I think that causes a subshell to spawn, the effects of which I'm not certain about. Further Googling suggests that the exit status of a pipeline is that of the most recently executed foreground pipeline, meaning that the exit code can be used directly in conditional statements. --- tools/validate-xep0001-conformance.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/validate-xep0001-conformance.sh b/tools/validate-xep0001-conformance.sh index cf073165..72b71314 100755 --- a/tools/validate-xep0001-conformance.sh +++ b/tools/validate-xep0001-conformance.sh @@ -18,7 +18,7 @@ VALIDATION_RESULT=0 # 1. Check DTD conformance against xep.dtd XEP_DTD="xep.dtd" -if (xmllint --noout --dtdvalid "$XEP_DTD" "$1") +if xmllint --noout --dtdvalid "$XEP_DTD" "$1" then echo "[PASS] DTD conformance against xep.dtd" else @@ -32,7 +32,7 @@ HEADER_STATUS=$(xmllint --xpath '/xep/header/status/text()' --nowarning --dtdval HEADER_TYPE=$(xmllint --xpath '/xep/header/type/text()' --nowarning --dtdvalid "$XEP_DTD" $1) HEADER_APPROVER=$(xmllint --xpath '/xep/header/approver/text()' --nowarning --dtdvalid "$XEP_DTD" $1) -if (echo "$FILE_NAME" | grep -Eq "^xep-[0-9]{4}.xml$") +if echo "$FILE_NAME" | grep -Eq "^xep-[0-9]{4}.xml$" then echo "[INFO] The filename ('$FILE_NAME') matches 'xep-[0-9]{4}.xml'." # 2. If the filename matches xep-[0-9]{4}.xml, check: @@ -66,7 +66,7 @@ else fi # 3.3 That the name does not start with xep-[0-9] - if (echo "$FILE_NAME" | grep -Eq "^xep-[0-9].*$") + if echo "$FILE_NAME" | grep -Eq "^xep-[0-9].*$" then echo "[FAIL] The filename ('$FILE_NAME') starts with 'xep-[0-9]' (but should not)." VALIDATION_RESULT=1;