From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: samer Newsgroups: gmane.emacs.bugs Subject: bug#12689: 24.2; Eshell ${cmd} substitution Date: Sun, 14 Dec 2014 04:44:04 -0800 Message-ID: <6c864c7f4302d40af7827e5f7ed7a100@samertm.com> References: <87wqyl1sa6.fsf@dimension8.tehua.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1418561129 16359 80.91.229.3 (14 Dec 2014 12:45:29 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 14 Dec 2014 12:45:29 +0000 (UTC) Cc: 12689@debbugs.gnu.org To: Aidan Gauland Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Dec 14 13:45:21 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Y08Y4-0001b1-Cr for geb-bug-gnu-emacs@m.gmane.org; Sun, 14 Dec 2014 13:45:20 +0100 Original-Received: from localhost ([::1]:35770 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y08Xy-0004ba-Uo for geb-bug-gnu-emacs@m.gmane.org; Sun, 14 Dec 2014 07:45:14 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55503) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y08Xs-0004Zk-38 for bug-gnu-emacs@gnu.org; Sun, 14 Dec 2014 07:45:12 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y08Xn-0000xN-0C for bug-gnu-emacs@gnu.org; Sun, 14 Dec 2014 07:45:08 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:35946) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y08Xm-0000wx-Sd for bug-gnu-emacs@gnu.org; Sun, 14 Dec 2014 07:45:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Y08Xm-0003rM-Af for bug-gnu-emacs@gnu.org; Sun, 14 Dec 2014 07:45:02 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: <87wqyl1sa6.fsf@dimension8.tehua.net> Resent-From: samer Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 14 Dec 2014 12:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12689 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 12689-submit@debbugs.gnu.org id=B12689.141856107414789 (code B ref 12689); Sun, 14 Dec 2014 12:45:02 +0000 Original-Received: (at 12689) by debbugs.gnu.org; 14 Dec 2014 12:44:34 +0000 Original-Received: from localhost ([127.0.0.1]:45312 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Y08XJ-0003qR-Rt for submit@debbugs.gnu.org; Sun, 14 Dec 2014 07:44:34 -0500 Original-Received: from samertm.com ([162.243.37.26]:40113 helo=mail.samertm.com) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Y08XG-0003qI-Ve for 12689@debbugs.gnu.org; Sun, 14 Dec 2014 07:44:32 -0500 Original-Received: from samertm.com (localhost [127.0.0.1]) by mail.samertm.com (Postfix) with ESMTP id 7B75481133; Sun, 14 Dec 2014 12:44:04 +0000 (UTC) X-Sender: samer@samertm.com User-Agent: Roundcube Webmail/0.9.5 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:97324 Archived-At: There are two issues contained in this bug: eshell-plain-command doesn't wait for the process to finish before returning, and echo parses output from subcommands as lisp objects instead of as args. The following patch makes eshell wait for external commands to finish before getting their output. The second bug is more complicated. Arguments are parsed with eshell-parse-arguments, which takes into account eshell's rules and syntax. When things are run in subshells, they're converted to lisp objects with eshell-convert, with no further processing. For example, for the command "echo ${/bin/echo hello there}" the subshell will return "hello there", which is seen as a single argument by the outer "echo". This isn't a big deal, but it means some constructions won't make sense. For instance: $ echo hello there ("hello" "there") $ echo ${/bin/echo hello there} hello there I tried hacking with eshell-parse-variable-ref to parse the arguments correctly, but it's trickier than it seems at first glance, so I'll work on it later. This patch gets us 90% of the way there, though. Best, Samer ---- Patch below ---- Changes from HEAD to working tree 2 files changed, 6 insertions(+), 1 deletion(-) lisp/ChangeLog | 5 +++++ lisp/eshell/esh-cmd.el | 2 +- Modified lisp/ChangeLog diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 45ba279..aa00661 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2014-12-14 Samer Masterson + + * eshell/esh-cmd.el (eshell-plain-command): Wait for subprocess to + finish before evaluating command (bug#12680). + 2014-11-28 Martin Rudalics Fix two issues around help-window-select. (Bug#11039) (Bug#19012) Modified lisp/eshell/esh-cmd.el diff --git a/lisp/eshell/esh-cmd.el b/lisp/eshell/esh-cmd.el index d20b66a..f17aa41 100644 --- a/lisp/eshell/esh-cmd.el +++ b/lisp/eshell/esh-cmd.el @@ -1241,7 +1241,7 @@ or an external command." (or esym eshell-prefer-lisp-functions (not (eshell-search-path command)))) (eshell-lisp-command sym args) - (eshell-external-command command args)))) + (eshell-wait-for-process (eshell-external-command command args))))) (defun eshell-exec-lisp (printer errprint func-or-form args form-p) "Execute a lisp FUNC-OR-FORM, maybe passing ARGS.