diff mbox

[maintainer-tools,5/7] dim: move empty name logic to function

Message ID 20170809111101.11315-5-eric.engestrom@imgtec.com (mailing list archive)
State New, archived
Headers show

Commit Message

Eric Engestrom Aug. 9, 2017, 11:10 a.m. UTC
Fair warning: this slightly changes the behaviour, as $testname would
previously contain the email if $testcc didn't contain a name.
Shouldn't affect anything though.

Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com>
---
 dim | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
diff mbox

Patch

diff --git a/dim b/dim
index 4ffac497c621..481a53e23035 100755
--- a/dim
+++ b/dim
@@ -1965,7 +1965,9 @@  function email_get_address
 
 function email_get_name
 {
-	sed -e 's/[[:space:]]*<.*$//' <<< "$1"
+	if grep -q '<' <<< "$1"; then
+		sed -e 's/[[:space:]]*<.*$//' <<< "$1"
+	fi
 }
 
 function dim_add_missing_cc
@@ -1977,11 +1979,7 @@  function dim_add_missing_cc
 
 	git show | scripts/get_maintainer.pl --email --norolestats --pattern-depth 1 | while read cc; do
 		email="$(email_get_address "$cc")"
-		name=''
-
-		if echo "$cc" | grep -q '<'; then
-			name="$(email_get_name "$cc")";
-		fi
+		name="$(email_get_name "$cc")"
 
 		# Don't add main mailing lists
 		if [ "$email" = "dri-devel@lists.freedesktop.org" -o \