From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 835D76DE1016 for ; Sat, 19 Aug 2017 14:31:38 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 0.489 X-Spam-Level: X-Spam-Status: No, score=0.489 tagged_above=-999 required=5 tests=[AWL=-0.163, SPF_NEUTRAL=0.652] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OW_WJO_zftSQ for ; Sat, 19 Aug 2017 14:31:37 -0700 (PDT) Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) by arlo.cworth.org (Postfix) with ESMTP id 93E5B6DE1006 for ; Sat, 19 Aug 2017 14:31:35 -0700 (PDT) Received: from guru.guru-group.fi (localhost [IPv6:::1]) by guru.guru-group.fi (Postfix) with ESMTP id DA4DA100090; Sun, 20 Aug 2017 00:31:15 +0300 (EEST) From: Tomi Ollila To: Joseph Mingrone Cc: notmuch@freelists.org, notmuch@notmuchmail.org Subject: Re: proposed patches to notmuch-emacs-mua In-Reply-To: <861so7i9xy.fsf@phe.ftfl.ca> References: <86lgngplvt.fsf@phe.ftfl.ca> <861so7i9xy.fsf@phe.ftfl.ca> User-Agent: Notmuch/0.25+45~g08b726a (https://notmuchmail.org) Emacs/25.2.1 (x86_64-unknown-linux-gnu) X-Face: HhBM'cA~ MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 Aug 2017 21:31:38 -0000 On Sat, Aug 19 2017, Joseph Mingrone wrote: > Hello Tomi, > > Tomi Ollila 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. if you try strace -ff -o forks -e trace=execve sh -c 'echo $(printf %s\\n foo | sed s/o/a/)' you get 4 files. one is surrounding sh and 3 are forks creating that pipeline. in one of those 3 forks sed(1) is execve'd. it takes some time to execute these system calls instead of just doing internal bash string handling. But we'd get (possibly, YMMV) clearer solution my just doing case $3 in *['"\']*) __escape_arg__=$(printf '%s' "$3" | sed -e 's|\\|\\\\|g' -e 's|\"|\\\"|g') eval $2=\$__escape_arg__ ;; *) eval $2=\$3 esac i.e. execute pipeline only when there is something to be escaped... > 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. > >>> Users may call, e.g., mml-secure-message-sign to insert MML at the top >>> of the message. By using message-goto-signature to insert file >>> contents into the body of the message, the MML remains at the top. > >> looks reasonable... this probably doesn't https://xkcd.com/1172/ ... > > You are targeting Emacs mail users. Is it an esoteric workflow to, > e.g., sign and encrypt mail messages? It sure is not ... :D > >> The changes in this 3/3 up to this point looks good, but the change below >> is somewhat controversial. It is convenient that $EMACS is split to command >> and arguments on $IFS variables (space, tab, newline). Some tools use >> similar approach; e.g. I just used GIT_SSH_COMMAND='ssh -vvv' git pull to >> debug failing ssh login (it did not help, sudo strace -f -p was >> to the rescue this time ;) > >>> if [ -n "$USE_EMACSCLIENT" ]; then >>> # Evaluate the progn. >>> - exec ${EMACSCLIENT} ${NO_WINDOW} ${CREATE_FRAME} ${AUTO_DAEMON} --eval "${ELISP}" >>> + exec "${EMACSCLIENT}" ${NO_WINDOW} ${CREATE_FRAME} ${AUTO_DAEMON} --eval "${ELISP}" >>> else >>> - exec ${EMACS} ${NO_WINDOW} --eval "${ELISP}" >>> + exec "${EMACS}" ${NO_WINDOW} --eval "${ELISP}" >>> fi >>> -- >>> 2.13.3 > > Agreed. I take back this suggested change. > > Regards, > > Joseph