proposed patches to notmuch-emacs-mua

Jani Nikula jani at nikula.org
Sun Aug 20 05:33:09 PDT 2017


On Sat, 19 Aug 2017, Joseph Mingrone <jrm at ftfl.ca> wrote:
> Hello Tomi,
>
> Tomi Ollila <tomi.ollila at iki.fi> writes:
>> I'd like to know why bash is to be replaced; (e.g. since it is not in base
>> system, but so not is e.g. emacs...)
>
>> if this couple of order of magnitude heavier solution is used, then it
>> could be first checked whether to do so; e.g using case $3 in *['"\']*) and
>> and then do escaping on the need basis (an option to use posix shell
>> constructs to do such a thing looks probably too complicated... (*))
>
> Indeed, bash could be pulled in as a dependency to notmuch, but I'm
> shell shocked to hear you say the POSIX sh solution is an order of
> magnitude heavier than the bash solution.  Building on your suggestion,
> maybe this function is a reasonable alternative that doesn't call an
> external command.
>
> escape ()
> {
>   r=$3 p=
>   while case $r in *\\*) true ;; *) false ;; esac; do
>     p=$p${r%%\\*}\\\\ r=${r#*\\}
>   done
>   r="$p$r" p=
>
>   while case $r in *\"*) true ;; *) false ;; esac; do
>     p=$p${r%%\"*}\\\" r=${r#*\"}
>   done
>
>   eval "$2=\$p\$r"
> }
>
> It's no big deal either way.  I just followed a convention when updating
> the FreeBSD notmuch package.  If the script is close to POSIX
> compliance, then patch out the bashisms, otherwise pull in bash.  Why
> not attempt to comply to a standard and not pull in an external
> dependency (for some systems) when the script is already so close?  I
> thought I would upstream those changes in case they were useful.

IMHO don't fix it if it isn't broken. The proposed solutions to "fix"
the bashism are more complicated than the original, and might introduce
bugs. And sticking to sh here blocks future use of useful bashisms.

BR,
Jani.


More information about the notmuch mailing list