Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm running Emacs on Windows-XP SP3 GNU Emacs 22.3.1 (i386-mingw-nt5.1.2600) of 2008-09-07 on SOFT-MJASON

When I run a command where the argument contains shell meta-characters, my Emacs region is not passed to the command via STDIN as expected. I've written a program to verify that this is the case:

## test.pl
my $lines = 0;
while (<STDIN>)
{
    ++$lines;
}

print "Input lines: $lines\n";

for (my $i = 0; $i < @ARGV; ++$i)
{
    print "$i: [[$ARGV[$i]]]\n";
}

For example, if the region contains:

a
b

And I run: perl c:\bin\test.pl "<", I get:

Input lines: 0
0: [[<]]

If instead I run: perl c:\bin\test.pl "-", I get:

Input lines: 2
0: [[-]]

My SHELL environment variable within Emacs is set to c:/emacs/bin/cmdproxy.exe

This has never been a problem until I started running a recent version of Emacs. Does anyone know how to fix this? (I'm not interested in using any cygwin shell as my emacs shell)
Edit:
Any argument to test.pl I use that contains a shell meta-character has the same effect as using "<". For example passing "foo&" also results in "Input Lines: 0"

Similarly, any argument to test.pl I use that does not contain a shell meta-character has the same effect as using "-". For example passing "foo" also results in "Input Lines: 2"

share|improve this question

1 Answer 1

Using < indicates to the subprocess that you want to redirect from a named file, which Emacs is not supplying. This is why you get 0 input lines.

Using - indicates to subprocess should expect input on stdin, which Emacs is supplying, and the shell is properly calculating 2 lines.

share|improve this answer
    
My Perl program does not interpret "<" and "-" in this way. Is there something else in the call chain that does? For example cmdproxy? Since these arguments are quoted, why would that be happening? Also, "<" can be replaced by anything containing a shell-metacharacter and the effect will be the same, for example "foo&" also gives "Input Lines: 0". And "-" can be replaced by anything not containing a shell meta-character and the effect will be the same, for example "foo" also gives "Input lines: 2" –  Adrian Pronk Aug 30 '10 at 21:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.