GNU bug report logs -
#1388
23.0.60; Emacs shell problem with echo "1+1" | bc
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 1388 in the body.
You can then email your comments to 1388 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Message #3 received at quiet <at> emacsbugs.donarmstrong.com (full text, mbox):
[Message part 1 (text/plain, inline)]
[ Edited resend from
http://lists.gnu.org/archive/html/emacs-devel/2008-05/msg00349.html ]
Type the following after M-x eshell RET:
echo "1+1" | bc
and then the return key. Instead of the expected answer 2, eshell
displays:
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
now type the return key again. Here the answer is shown:
2
type the return key again. Nothing happens. Eshell blocks. Control-C
shows:
(interrupt) use quit to exit.
In GNU Emacs 23.0.60.3 (i686-pc-linux-gnu, GTK+ Version 2.8.20)
of 2008-05-06 on golem
Windowing system distributor `The X.Org Foundation', version 11.0.70000000
configured using `configure '--enable-font-backend--with-gtk'
'--with-gif=no''
Information forwarded to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#1388
; Package
emacs
.
Full text and
rfc822 format available.
Message #6 received at 1388 <at> emacsbugs.donarmstrong.com (full text, mbox):
"Jhair Tocancipa Triana" wrote:
> Type the following after M-x eshell RET:
>
> echo "1+1" | bc
>
> and then the return key. Instead of the expected answer 2, eshell
> displays:
>
> bc 1.06
> Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
[...]
I think this is because isatty(0) returns 1 on the right-hand side of
an eshell pipe, so bc thinks it is running interactively. Does anyone
know if that is fixable?
Information forwarded to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#1388
; Package
emacs
.
Full text and
rfc822 format available.
Acknowledgement sent to
Stefan Monnier <monnier <at> iro.umontreal.ca>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
Full text and
rfc822 format available.
Message #11 received at 1388 <at> emacsbugs.donarmstrong.com (full text, mbox):
>> echo "1+1" | bc
>> and then the return key. Instead of the expected answer 2, eshell
>> displays:
>> bc 1.06
>> Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
> I think this is because isatty(0) returns 1 on the right-hand side of
> an eshell pipe, so bc thinks it is running interactively. Does anyone
> know if that is fixable?
Yes, an appropriate binding of process-connection-type at the right
place and the right time should do the trick.
Stefan
Information forwarded to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#1388
; Package
emacs
.
Full text and
rfc822 format available.
Message #14 received at 1388 <at> emacsbugs.donarmstrong.com (full text, mbox):
Stefan Monnier wrote:
> Yes, an appropriate binding of process-connection-type at the right
> place and the right time should do the trick.
Awesome, thanks. The following seems to work, though:
i) One needs to use either /bin/echo or set eshell-plain-echo-behavior
non-nil if `echo 1+1 | bc' is to work.
ii) I'm not sure whether the following is mistakenly changing the
behaviour of the first command in a pipeline. Can't think of a good
test for that...
*** esh-proc.el.~1.21.~ 2008-05-20 16:28:53.000000000 -0700
--- esh-proc.el 2008-11-22 12:55:59.000000000 -0800
***************
*** 250,260 ****
(cond
((fboundp 'start-process)
(setq proc
(apply 'start-process
(file-name-nondirectory command) nil
! ;; `start-process' can't deal with relative
! ;; filenames
! (append (list (expand-file-name command)) args)))
(eshell-record-process-object proc)
(set-process-buffer proc (current-buffer))
(if (eshell-interactive-output-p)
--- 250,263 ----
(cond
((fboundp 'start-process)
(setq proc
+ ;; Bug#1388. Some commands (eg bc) check isatty to decide
+ ;; whether they are being called interactively.
+ (let ((process-connection-type (unless eshell-in-pipeline-p
+ process-connection-type)))
(apply 'start-process
(file-name-nondirectory command) nil
! ;; `start-process' can't deal with relative filenames
! (append (list (expand-file-name command)) args))))
(eshell-record-process-object proc)
(set-process-buffer proc (current-buffer))
(if (eshell-interactive-output-p)
Information forwarded to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#1388
; Package
emacs
.
Full text and
rfc822 format available.
Acknowledgement sent to
Glenn Morris <rgm <at> gnu.org>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
Full text and
rfc822 format available.
Message #19 received at 1388 <at> emacsbugs.donarmstrong.com (full text, mbox):
I've installed a fix that sets process-connection-type to nil for
every element of a pipeline but the first. Or do you think the first
element should have p-c-t nil as well?
Currently, the first/last elements in an eshell pipeline have:
stdin = tty/non-tty, stdout = tty/non-tty;
whereas in a "real" shell pipeline they have:
stdin = tty/non-tty, stdout = non-tty/tty;
ie I chose to get the input right over the output.
Reply sent to
Glenn Morris <rgm <at> gnu.org>
:
You have taken responsibility.
Full text and
rfc822 format available.
Notification sent to
"Jhair Tocancipa Triana" <jhair.tocancipa <at> gmail.com>
:
bug acknowledged by developer.
Full text and
rfc822 format available.
Message #24 received at 1388-done <at> emacsbugs.donarmstrong.com (full text, mbox):
Thanks for the report; sorry for the long delay in responding.
This should be fixed in the current CVS. You still need to use
/bin/echo, or set eshell-plain-echo-behavior non-nil, for it to work right.
Information forwarded to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#1388
; Package
emacs
.
Full text and
rfc822 format available.
Acknowledgement sent to
Stefan Monnier <monnier <at> iro.umontreal.ca>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
Full text and
rfc822 format available.
Message #29 received at 1388 <at> emacsbugs.donarmstrong.com (full text, mbox):
> I've installed a fix that sets process-connection-type to nil for
> every element of a pipeline but the first. Or do you think the first
> element should have p-c-t nil as well?
> Currently, the first/last elements in an eshell pipeline have:
> stdin = tty/non-tty, stdout = tty/non-tty;
> whereas in a "real" shell pipeline they have:
> stdin = tty/non-tty, stdout = non-tty/tty;
> ie I chose to get the input right over the output.
Not sure if it's better in general.
Maybe we should just leave the code as is for now, but add a comment
explaining the problem. For the longer term we can either try your
approach, or better try and come up with a way to make it work right
(i.e. extending start-process).
Stefan
Information forwarded to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#1388
; Package
emacs
.
Full text and
rfc822 format available.
Message #32 received at 1388 <at> emacsbugs.donarmstrong.com (full text, mbox):
Stefan Monnier wrote:
> Not sure if it's better in general.
> Maybe we should just leave the code as is for now, but add a comment
> explaining the problem. For the longer term we can either try your
> approach,
I'm happy to make changes, but I'm not sure what you are saying here.
Do you want me to just set process-connection-type nil for every
element of an eshell pipe, including the first? What I installed was
the version where the first command gets p-c-t non-nil (actually,
whatever the default is).
Information forwarded to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#1388
; Package
emacs
.
Full text and
rfc822 format available.
Acknowledgement sent to
Stefan Monnier <monnier <at> iro.umontreal.ca>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
Full text and
rfc822 format available.
Message #37 received at 1388 <at> emacsbugs.donarmstrong.com (full text, mbox):
>> Not sure if it's better in general.
>> Maybe we should just leave the code as is for now, but add a comment
>> explaining the problem. For the longer term we can either try your
>> approach,
> I'm happy to make changes, but I'm not sure what you are saying here.
> Do you want me to just set process-connection-type nil for every
> element of an eshell pipe, including the first? What I installed was
> the version where the first command gets p-c-t non-nil (actually,
> whatever the default is).
"as is" means, as it was when the OP bumped into the problem.
I see you've already made a change to eshell, but I was not referring
to that.
Stefan
Information forwarded to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#1388
; Package
emacs
.
Full text and
rfc822 format available.
Message #40 received at 1388 <at> emacsbugs.donarmstrong.com (full text, mbox):
Stefan Monnier wrote:
> "as is" means, as it was when the OP bumped into the problem.
Oh, OK, so you want me to take out my changes...
> I see you've already made a change to eshell, but I was not referring
> to that.
...now you've gone and confused me again! :)
Maybe you mean, eshell changes ok, but leave start-process as is,
which I would certainly agree with?
Sorry for being obtuse...
Information forwarded to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#1388
; Package
emacs
.
Full text and
rfc822 format available.
Acknowledgement sent to
Stefan Monnier <monnier <at> iro.umontreal.ca>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
Full text and
rfc822 format available.
Message #45 received at 1388 <at> emacsbugs.donarmstrong.com (full text, mbox):
>> "as is" means, as it was when the OP bumped into the problem.
> Oh, OK, so you want me to take out my changes...
Yes, I think they're not "obviously better" enough. Maybe they are, but
I'd need some convincing.
Stefan
Information forwarded to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#1388
; Package
emacs
.
Full text and
rfc822 format available.
Message #48 received at 1388 <at> emacsbugs.donarmstrong.com (full text, mbox):
reopen 1388
stop
Stefan Monnier wrote:
>>> "as is" means, as it was when the OP bumped into the problem.
>> Oh, OK, so you want me to take out my changes...
>
> Yes, I think they're not "obviously better" enough. Maybe they are, but
> I'd need some convincing.
OK, change reverted, bug re-opened.
Given that said change solves the reported bug, and I was just
following your own suggestion on what to do, I'm thoroughly confused.
(But this is not atypical.)
bug reopened, originator not changed.
Request was from
Glenn Morris <rgm <at> gnu.org>
to
control <at> emacsbugs.donarmstrong.com
.
(Tue, 25 Nov 2008 04:40:05 GMT)
Full text and
rfc822 format available.
Information forwarded to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#1388
; Package
emacs
.
Full text and
rfc822 format available.
Acknowledgement sent to
Stefan Monnier <monnier <at> iro.umontreal.ca>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
Full text and
rfc822 format available.
Message #55 received at 1388 <at> emacsbugs.donarmstrong.com (full text, mbox):
> OK, change reverted, bug re-opened.
Thank you.
> Given that said change solves the reported bug, and I was just
> following your own suggestion on what to do, I'm thoroughly confused.
> (But this is not atypical.)
My suggestion was for how to fix the particular circumstance. I didn't
imply that it would fix the problem in general. And indeed, you've
found that there's a fundamental problem in how we handle processes that
seems to make it impossible right now to reproduce what a normal shell
would do.
This said, I haven't looked closely enough to know that your change
might make things worse in some cases. But it doesn't seem
obviously safe. So maybe you can convince me that it's not making
things worse in other circumstances, or that those circumstances are
much less likely (or didn't work well anyway in the past for other
reasons).
Stefan
Information forwarded to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#1388
; Package
emacs
.
Full text and
rfc822 format available.
Message #58 received at 1388 <at> emacsbugs.donarmstrong.com (full text, mbox):
Stefan Monnier wrote:
> So maybe you can convince me that it's not making things worse in
> other circumstances, or that those circumstances are much less
> likely (or didn't work well anyway in the past for other reasons).
Let's see:
i) I didn't change the behaviour for the first element in a pipeline.
ii) For the "middle" elements, it must be more correct to uses pipes,
must it not?
iii) For the last element, I dunno. One has to use pipes for the bc
case to get the right result. Checking if the final command in a
pipeline looks like "bc" and if so doing something special seems like
an ugly hack. That's about all I can say.
Reply sent to
Glenn Morris <rgm <at> gnu.org>
:
You have taken responsibility.
Full text and
rfc822 format available.
Notification sent to
"Jhair Tocancipa Triana" <jhair.tocancipa <at> gmail.com>
:
bug acknowledged by developer.
Full text and
rfc822 format available.
Message #63 received at 1388-done <at> emacsbugs.donarmstrong.com (full text, mbox):
Glenn Morris wrote:
> Checking if the final command in a pipeline looks like "bc" and if
> so doing something special seems like an ugly hack.
On second thoughts, no it doesn't, and I installed something along
those lines.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> emacsbugs.donarmstrong.com
.
(Thu, 15 Jan 2009 15:24:05 GMT)
Full text and
rfc822 format available.
This bug report was last modified 15 years and 182 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.