#!/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" = '-b' ]; 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>'
+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}"
-filter="sed -e 's/BRANCH/$branch/g'"
-[ "$kconfig" ] &&
- filter="$filter -e 's/KCONFIG_NAME/$kconfig/g'"
-filter="$filter | fmt -s"
-
-{ printf 'Hi all,\n\n'; eval "$filter"; } |
- "$bin_dir"/send_email "$contact" "$cc" "linux-next: $subject"
+subject=${1//BRANCH/$branch}
+filter=( -e "s/BRANCH/$branch/g" )
+if [ -n "$kconfig" ]; then
+ filter+=( -e "s/KCONFIG_NAME/$kconfig/g" )
+fi
+
+{
+ printf 'Hi all,\n\n'
+ sed "${filter[@]}" | fmt -s
+} | "$bin_dir"/send_email "linux-next: $subject" "$contact" "${cc[@]}"
exit 0