unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#1388: 23.0.60; Emacs shell problem with echo "1+1" | bc
       [not found] ` <dfiqqisu34.fsf@fencepost.gnu.org>
@ 2008-11-22  1:46   ` Glenn Morris
  2008-11-22  4:03     ` Stefan Monnier
  2008-11-23  3:25   ` bug#1388: marked as done (23.0.60; Emacs shell problem with echo "1+1" | bc) Emacs bug Tracking System
  2008-11-30  1:35   ` Emacs bug Tracking System
  2 siblings, 1 reply; 15+ messages in thread
From: Glenn Morris @ 2008-11-22  1:46 UTC (permalink / raw)
  To: 1388

"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?






^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#1388: 23.0.60; Emacs shell problem with echo "1+1" | bc
  2008-11-22  1:46   ` bug#1388: 23.0.60; Emacs shell problem with echo "1+1" | bc Glenn Morris
@ 2008-11-22  4:03     ` Stefan Monnier
  2008-11-22 21:02       ` Glenn Morris
  0 siblings, 1 reply; 15+ messages in thread
From: Stefan Monnier @ 2008-11-22  4:03 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 1388

>> 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






^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#1388: 23.0.60; Emacs shell problem with echo "1+1" | bc
  2008-11-22  4:03     ` Stefan Monnier
@ 2008-11-22 21:02       ` Glenn Morris
  2008-11-23  3:12         ` Glenn Morris
  0 siblings, 1 reply; 15+ messages in thread
From: Glenn Morris @ 2008-11-22 21:02 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 1388

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)






^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#1388: 23.0.60; Emacs shell problem with echo "1+1" | bc
  2008-11-22 21:02       ` Glenn Morris
@ 2008-11-23  3:12         ` Glenn Morris
  2008-11-23  4:28           ` Stefan Monnier
  0 siblings, 1 reply; 15+ messages in thread
From: Glenn Morris @ 2008-11-23  3:12 UTC (permalink / raw)
  To: Stefan Monnier, 1388


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.






^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#1388: marked as done (23.0.60; Emacs shell problem with echo  "1+1" | bc)
       [not found] ` <dfiqqisu34.fsf@fencepost.gnu.org>
  2008-11-22  1:46   ` bug#1388: 23.0.60; Emacs shell problem with echo "1+1" | bc Glenn Morris
@ 2008-11-23  3:25   ` Emacs bug Tracking System
  2008-11-30  1:35   ` Emacs bug Tracking System
  2 siblings, 0 replies; 15+ messages in thread
From: Emacs bug Tracking System @ 2008-11-23  3:25 UTC (permalink / raw)
  To: Glenn Morris

[-- Attachment #1: Type: text/plain, Size: 876 bytes --]


Your message dated Sat, 22 Nov 2008 22:16:28 -0500
with message-id <9askpji12r.fsf@fencepost.gnu.org>
and subject line Re: bug#1388: 23.0.60; Emacs shell problem with echo "1+1" | bc
has caused the Emacs bug report #1388,
regarding 23.0.60; Emacs shell problem with echo "1+1" | bc
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact don@donarmstrong.com
immediately.)


-- 
1388: http://emacsbugs.donarmstrong.com/cgi-bin/bugreport.cgi?bug=1388
Emacs Bug Tracking System
Contact don@donarmstrong.com with problems

[-- Attachment #2: Type: message/rfc822, Size: 6311 bytes --]

[-- Attachment #2.1.1: Type: text/plain, Size: 803 bytes --]


[ 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''


[-- Attachment #3: Type: message/rfc822, Size: 1766 bytes --]

From: Glenn Morris <rgm@gnu.org>
To: 1388-done@emacsbugs.donarmstrong.com
Subject: Re: bug#1388: 23.0.60; Emacs shell problem with echo "1+1" | bc
Date: Sat, 22 Nov 2008 22:16:28 -0500
Message-ID: <9askpji12r.fsf@fencepost.gnu.org>


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.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#1388: 23.0.60; Emacs shell problem with echo "1+1" | bc
  2008-11-23  3:12         ` Glenn Morris
@ 2008-11-23  4:28           ` Stefan Monnier
  2008-11-24  7:47             ` Glenn Morris
  0 siblings, 1 reply; 15+ messages in thread
From: Stefan Monnier @ 2008-11-23  4:28 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 1388

> 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






^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#1388: 23.0.60; Emacs shell problem with echo "1+1" | bc
  2008-11-23  4:28           ` Stefan Monnier
@ 2008-11-24  7:47             ` Glenn Morris
  2008-11-24 16:15               ` Stefan Monnier
  0 siblings, 1 reply; 15+ messages in thread
From: Glenn Morris @ 2008-11-24  7:47 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 1388

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).






^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#1388: 23.0.60; Emacs shell problem with echo "1+1" | bc
  2008-11-24  7:47             ` Glenn Morris
@ 2008-11-24 16:15               ` Stefan Monnier
  2008-11-24 17:26                 ` Glenn Morris
  0 siblings, 1 reply; 15+ messages in thread
From: Stefan Monnier @ 2008-11-24 16:15 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 1388

>> 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






^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#1388: 23.0.60; Emacs shell problem with echo "1+1" | bc
  2008-11-24 16:15               ` Stefan Monnier
@ 2008-11-24 17:26                 ` Glenn Morris
  2008-11-25  3:21                   ` Stefan Monnier
  0 siblings, 1 reply; 15+ messages in thread
From: Glenn Morris @ 2008-11-24 17:26 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 1388

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...






^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#1388: 23.0.60; Emacs shell problem with echo "1+1" | bc
  2008-11-24 17:26                 ` Glenn Morris
@ 2008-11-25  3:21                   ` Stefan Monnier
  2008-11-25  4:31                     ` Glenn Morris
  0 siblings, 1 reply; 15+ messages in thread
From: Stefan Monnier @ 2008-11-25  3:21 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 1388

>> "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






^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#1388: 23.0.60; Emacs shell problem with echo "1+1" | bc
  2008-11-25  3:21                   ` Stefan Monnier
@ 2008-11-25  4:31                     ` Glenn Morris
  2008-11-25  4:40                       ` Processed: " Emacs bug Tracking System
  2008-11-27 18:21                       ` Stefan Monnier
  0 siblings, 2 replies; 15+ messages in thread
From: Glenn Morris @ 2008-11-25  4:31 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 1388

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.)






^ permalink raw reply	[flat|nested] 15+ messages in thread

* Processed: Re: bug#1388: 23.0.60; Emacs shell problem with echo "1+1" | bc
  2008-11-25  4:31                     ` Glenn Morris
@ 2008-11-25  4:40                       ` Emacs bug Tracking System
  2008-11-27 18:21                       ` Stefan Monnier
  1 sibling, 0 replies; 15+ messages in thread
From: Emacs bug Tracking System @ 2008-11-25  4:40 UTC (permalink / raw)
  To: Glenn Morris; +Cc: Emacs Bugs

Processing commands for control@emacsbugs.donarmstrong.com:

> reopen 1388
bug#1388: 23.0.60; Emacs shell problem with echo "1+1" | bc
bug reopened, originator not changed.

> stop
Stopping processing here.

Please contact me if you need assistance.

Don Armstrong
(administrator, Emacs bugs database)





^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#1388: 23.0.60; Emacs shell problem with echo "1+1" | bc
  2008-11-25  4:31                     ` Glenn Morris
  2008-11-25  4:40                       ` Processed: " Emacs bug Tracking System
@ 2008-11-27 18:21                       ` Stefan Monnier
  2008-11-29  2:34                         ` Glenn Morris
  1 sibling, 1 reply; 15+ messages in thread
From: Stefan Monnier @ 2008-11-27 18:21 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 1388

> 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






^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#1388: 23.0.60; Emacs shell problem with echo "1+1" | bc
  2008-11-27 18:21                       ` Stefan Monnier
@ 2008-11-29  2:34                         ` Glenn Morris
  0 siblings, 0 replies; 15+ messages in thread
From: Glenn Morris @ 2008-11-29  2:34 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 1388

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.






^ permalink raw reply	[flat|nested] 15+ messages in thread

* bug#1388: marked as done (23.0.60; Emacs shell problem with echo  "1+1" | bc)
       [not found] ` <dfiqqisu34.fsf@fencepost.gnu.org>
  2008-11-22  1:46   ` bug#1388: 23.0.60; Emacs shell problem with echo "1+1" | bc Glenn Morris
  2008-11-23  3:25   ` bug#1388: marked as done (23.0.60; Emacs shell problem with echo "1+1" | bc) Emacs bug Tracking System
@ 2008-11-30  1:35   ` Emacs bug Tracking System
  2 siblings, 0 replies; 15+ messages in thread
From: Emacs bug Tracking System @ 2008-11-30  1:35 UTC (permalink / raw)
  To: Glenn Morris

[-- Attachment #1: Type: text/plain, Size: 876 bytes --]


Your message dated Sat, 29 Nov 2008 20:29:48 -0500
with message-id <mty6z22e7n.fsf@fencepost.gnu.org>
and subject line Re: bug#1388: 23.0.60; Emacs shell problem with echo "1+1" | bc
has caused the Emacs bug report #1388,
regarding 23.0.60; Emacs shell problem with echo "1+1" | bc
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact don@donarmstrong.com
immediately.)


-- 
1388: http://emacsbugs.donarmstrong.com/cgi-bin/bugreport.cgi?bug=1388
Emacs Bug Tracking System
Contact don@donarmstrong.com with problems

[-- Attachment #2: Type: message/rfc822, Size: 6311 bytes --]

[-- Attachment #2.1.1: Type: text/plain, Size: 803 bytes --]


[ 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''


[-- Attachment #3: Type: message/rfc822, Size: 2264 bytes --]

From: Glenn Morris <rgm@gnu.org>
To: 1388-done@emacsbugs.donarmstrong.com
Cc: Stefan Monnier <monnier@iro.umontreal.ca>
Subject: Re: bug#1388: 23.0.60; Emacs shell problem with echo "1+1" | bc
Date: Sat, 29 Nov 2008 20:29:48 -0500
Message-ID: <mty6z22e7n.fsf@fencepost.gnu.org>

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.


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2008-11-30  1:35 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <9askpji12r.fsf@fencepost.gnu.org>
     [not found] ` <dfiqqisu34.fsf@fencepost.gnu.org>
2008-11-22  1:46   ` bug#1388: 23.0.60; Emacs shell problem with echo "1+1" | bc Glenn Morris
2008-11-22  4:03     ` Stefan Monnier
2008-11-22 21:02       ` Glenn Morris
2008-11-23  3:12         ` Glenn Morris
2008-11-23  4:28           ` Stefan Monnier
2008-11-24  7:47             ` Glenn Morris
2008-11-24 16:15               ` Stefan Monnier
2008-11-24 17:26                 ` Glenn Morris
2008-11-25  3:21                   ` Stefan Monnier
2008-11-25  4:31                     ` Glenn Morris
2008-11-25  4:40                       ` Processed: " Emacs bug Tracking System
2008-11-27 18:21                       ` Stefan Monnier
2008-11-29  2:34                         ` Glenn Morris
2008-11-23  3:25   ` bug#1388: marked as done (23.0.60; Emacs shell problem with echo "1+1" | bc) Emacs bug Tracking System
2008-11-30  1:35   ` Emacs bug Tracking System

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).