#!/bin/bash
# shellcheck source=./common.sh
-. "$(dirname "$0")/common.sh" ""
+. "$(dirname "$0")/common.sh" ''
log="$LOG_FILE"
-[ -f merge.log ] && log=merge.log
+if [ -f merge.log ]; then
+ log='merge.log'
+fi
-branch=""
-[ "$1" = "-t" ] && {
- branch=$2
+branch=
+if [ "$1" = '-t' ]; then
+ branch="$2"
shift 2
-}
+fi
-kconfig=""
-[ "$1" = "-c" ] && {
- kconfig=$2
+kconfig=
+if [ "$1" = '-c' ]; then
+ kconfig="$2"
shift 2
-}
+fi
cc='Linux Next Mailing List <linux-next@vger.kernel.org>, Linux Kernel Mailing List <linux-kernel@vger.kernel.org>'
-[ "$branch" ] || {
- branch=$(grep '^Merging ' $log | tail -1 | sed 's/^Merging //' | sed 's/ .*$//')
- branch=${branch%%/*}
-}
+if [ -z "$branch" ]; then
+ branch=$(grep '^Merging ' "$log" | tail -n 1 |
+ sed 's/^Merging \([^ /]*\).*$/\1/')
+fi
contact=$(get_contacts "$branch")
-subject="${1//BRANCH/$branch}"
+subject=${1//BRANCH/$branch}
filter="sed -e 's/BRANCH/$branch/g'"
-[ "$kconfig" ] &&
+if [ "$kconfig" ]; then
filter="$filter -e 's/KCONFIG_NAME/$kconfig/g'"
+fi
filter="$filter | fmt -s"
{ printf 'Hi all,\n\n'; eval "$filter"; } |