From: Junio C Hamano Date: Sat, 09 Aug 2008 01:37:13 GMT Subject: Re: [TopGit PATCH] tg-create.sh: Support for multiple {to,cc,bcc} options Message-ID: <7vbq039dfa.fsf@gitster.siamese.dyndns.org> In-Reply-To: <20080809003357.GQ10151@machine.or.cz> Petr Baudis writes: >> + prefix="$(echo "$2" | sed -e 's/\//\\\\\//g')" > > Maybe use s### ? ;-) Personally I like '|' instead. It's much less visually distracting than #. >> + >> + git config --get-all topgit.$1 2>/dev/null | >> + sed -e "s/^/$prefix /g" >> +} > > Won't this return an error code and terminate the script in case no > option is defined? Exit code from upstream of a pipe does not affect the exit code from the pipeline, and sed does not exit non-zero just because there was no substitution. >> - ! header="$(git config topgit.to)" || echo "To: $header" >> - ! header="$(git config topgit.cc)" || echo "Cc: $header" >> - ! header="$(git config topgit.bcc)" || echo "Bcc: $header" >> + get_multi_config to "To:" >> + get_multi_config cc "Cc:" >> + get_multi_config bcc "Bcc:" >> ! subject_prefix="$(git config topgit.subjectprefix)" || subject_prefix="$subject_prefix " >> echo "Subject: [${subject_prefix}PATCH] $name" >> echo > > One trouble here is that I've seen mailers mess up when there is > multiple occurences of these headers, so it would be probably safer to > concatenate them all to single line, comma-separated. It is not just "I've seen mailers"; RFC2822 wants you to have at most one (see the table on Page 20).