#!/usr/bin/env bash
+SED=$(which gsed 2>/dev/null); SED=${SED:-sed}
+
yesno() {
local prompt="$1"
local default="${2:-n}"
)}
get_date() {
- date +"%a, %d %b %Y %H:%M:%S %z" | sed -e 's|, 0|, |'
+ date +"%a, %d %b %Y %H:%M:%S %z" | $SED -e 's|, 0|, |'
}
get_subject() {
local IFS="
"
- for line in $(sed -ne '/^Subject: */ { s/^Subject: *//p; :next; n; s/^ \+//p; t next; b }' "$1"); do
+ for line in $($SED -ne '/^Subject: */ { s/^Subject: *//p; :next; n; s/^ \+//p; t next; b }' "$1"); do
subject="$subject$line"
done
- printf "%s\n" "$subject" | sed -e 's/^\[.*\] *//'
+ printf "%s\n" "$subject" | $SED -e 's/^\[.*\] \+//'
}
get_hdr_list() {
local IFS=",
"
- for addr in $(sed -ne "/^$field: */ { s/^$field: *//p; :next; n; s/^ \\+//p; t next; b }" "$file"); do
- list="${list:+$list, }$(echo "$addr" | sed -e 's/^ \+//; s/ \+$//')"
+ for addr in $($SED -ne "/^$field: */ { s/^$field: *//p; :next; n; s/^ \\+//p; t next; b }" "$file"); do
+ list="${list:+$list, }$(echo "$addr" | $SED -e 's/^ \+//; s/ \+$//')"
done
[ -n "$list" ] && printf "%s: %s\n" "$field" "$list"
}
get_hdr() {
- sed -ne "s/^$2: *//p" "$1" | head -n1
+ $SED -ne "s/^$2: *//p" "$1" | head -n1
}
format_reply() {
esac
case "$remote_host" in
- git.lede-project.org|git.openwrt.org)
+ git.openwrt.org|git.lede-project.org)
case "$remote_repo" in
source.git|openwrt/openwrt.git)
- echo "Merged into ${remote_ref##*/} with"
+ echo "Merged into ${remote_ref##*/}."
;;
lede/*/staging.git|openwrt/staging/*.git)
- echo "Merged into my staging tree with"
+ echo "Merged into my staging tree."
;;
*)
- echo "Merged into ${remote_repo:-the repository}, branch ${remote_ref##*/} with"
+ echo "Merged into ${remote_repo:-the repository}, branch ${remote_ref##*/}."
;;
esac
;;
*)
- echo "Merged with"
+ echo "Merged."
;;
esac
- echo "http://$remote_host/?p=$remote_repo;a=commitdiff;h=$(git log -1 --format=%h)."
- echo ""
-
echo "Thank you!"
echo ""
}