From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#19643: 24.2; shell mode Date: Wed, 21 Jan 2015 17:49:54 +0200 Message-ID: <83bnlsw2u5.fsf@gnu.org> References: <83vbk1htzk.fsf@WILLIAM.i-did-not-set--mail-host-address--so-tickle-me> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1421855477 6523 80.91.229.3 (21 Jan 2015 15:51:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 21 Jan 2015 15:51:17 +0000 (UTC) Cc: 19643@debbugs.gnu.org To: twilliam@twilliam.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jan 21 16:51:16 2015 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 1YDxYo-0001l1-A5 for geb-bug-gnu-emacs@m.gmane.org; Wed, 21 Jan 2015 16:51:14 +0100 Original-Received: from localhost ([::1]:48870 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDxYn-0004QS-Ob for geb-bug-gnu-emacs@m.gmane.org; Wed, 21 Jan 2015 10:51:13 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57554) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDxYh-0004Mx-Nz for bug-gnu-emacs@gnu.org; Wed, 21 Jan 2015 10:51:09 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YDxYd-0000pl-Ct for bug-gnu-emacs@gnu.org; Wed, 21 Jan 2015 10:51:07 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:33322) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDxYd-0000pa-9L for bug-gnu-emacs@gnu.org; Wed, 21 Jan 2015 10:51:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1YDxYc-000454-BZ for bug-gnu-emacs@gnu.org; Wed, 21 Jan 2015 10:51:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 21 Jan 2015 15:51:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 19643 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 19643-submit@debbugs.gnu.org id=B19643.142185541115618 (code B ref 19643); Wed, 21 Jan 2015 15:51:02 +0000 Original-Received: (at 19643) by debbugs.gnu.org; 21 Jan 2015 15:50:11 +0000 Original-Received: from localhost ([127.0.0.1]:52014 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YDxXm-00043q-P3 for submit@debbugs.gnu.org; Wed, 21 Jan 2015 10:50:11 -0500 Original-Received: from mtaout25.012.net.il ([80.179.55.181]:39996) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YDxXg-00043B-Gi for 19643@debbugs.gnu.org; Wed, 21 Jan 2015 10:50:06 -0500 Original-Received: from conversion-daemon.mtaout25.012.net.il by mtaout25.012.net.il (HyperSendmail v2007.08) id <0NIJ00G00A6F8000@mtaout25.012.net.il> for 19643@debbugs.gnu.org; Wed, 21 Jan 2015 17:45:19 +0200 (IST) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by mtaout25.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NIJ007AOAFJQ190@mtaout25.012.net.il>; Wed, 21 Jan 2015 17:45:19 +0200 (IST) In-reply-to: <83vbk1htzk.fsf@WILLIAM.i-did-not-set--mail-host-address--so-tickle-me> X-012-Sender: halo1@inter.net.il 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:98544 Archived-At: > From: twilliam@twilliam.org > Date: Tue, 20 Jan 2015 17:12:31 -0700 > > I'm trying to use shell mode. In fact, I'm trying to run a Perl > program in shell mode. I launch the program, and it runs. Input from > a file is read, processed. Output (to STDOUT) is printed to *shell*. > Trouble is I can't read keyboard input (as in ). What am I > missing (except a brain)? > > Ok, this is Emacs 24.2.1 running on Windows XP. > > I downloaded Perl from ActiveState in 2011. Here's a simple Perl > program that demos the problem: > > print "Give me a number: "; > chomp ( $Anumber = ); > print "Give me another: "; > chomp ( $Bnumber = ); > $product = $Anumber * $Bnumber; > print "$Anumber times $Bnumber = $product\n"; > > It works fine in a DOS window. In emacs shell mode it tells me this > > Use of uninitialized value $Anumber in chomp at c:\Perl\ex2-4.pl line 3. > Use of uninitialized value $Bnumber in chomp at c:\Perl\ex2-4.pl line 5. > Use of uninitialized value $Bnumber in multiplication (*) at c:\Perl\ex2-4.pl > line 6. > Use of uninitialized value $Anumber in multiplication (*) at c:\Perl\ex2-4.pl > line 6. > Use of uninitialized value $Anumber in concatenation (.) or string at > c:\Perl\ex2-4.pl line 7. > Use of uninitialized value $Bnumber in concatenation (.) or string at > c:\Perl\ex2-4.pl line 7. > Give me a number: Give me another: times = 0 > > Perl is complaining about uninitialized values before it has even > printed the prompts for them. It's a buffering issue. On Windows, sub-processes are run via pipes, and Perl evidently fully buffers its stdout when it's connected to a pipe (as opposed to a console, where it is line-buffered, and is also flushed when your script reads from STDIN). There's nothing Emacs can do about this, because the decision about the buffering mode is made by the Perl interpreter. Some interpreters, like Python, have a command-line switch to turn off buffering, but Perl doesn't (AFAIK). So you need to do that from your Perl scripts. My Perl is exceedingly rudimentary, but I found the solution here: http://perl.plover.com/FAQs/Buffering.html http://www.perlmonks.org/?node_id=280025 The solution is to add this single line at the beginning of your Perl script: $|++; This causes STDOUT to auto-flush after each output. (There's also an alternative that needs to use the FileHandle module, see the first URL above.) Bottom line: I don't think this is an Emacs problem.