Bug #4396

windows commands starting with "@" should run at all even though command string is quoted by `"'.

Added by Motohiro KOSAKI about 3 years ago. Updated almost 3 years ago.

[ruby-core:35227]
Status:Rejected
Priority:Normal
Assignee:-
Category:core
Target version:1.9.3
ruby -v:ruby 1.9.3dev (2011-02-09 trunk 30831) [i386-mswin32_100] Backport:

Description

=begin
This issue

C test program.


main()
{
system("\"@echo foo\"");
}


=> foo

Ruby test program.


ruby -e 'p system("\"@echo foo\"")'

=> nil
=end


Related issues

Related to ruby-trunk - Bug #4393: windows commands starting with "@" should run at all Closed 02/13/2011

History

#1 Updated by Motohiro KOSAKI about 3 years ago

=begin
If you are writing C and you need to run "@echo" command, you should escape the string by `' (caret).

ie,


main()
{
system("@echo foo");
}


It's MSVCRT spec. I'm not sure ruby's system() method should follow it or not.
Maybe we need a discussion.
=end

#2 Updated by Jon Forums about 3 years ago

=begin
fwiw, behavior on win7 32-bit with lua v5.1.4 and python v2.7.1...

C:>lua -e "os.execute('@echo foo')"
foo

C:>lua -e "os.execute('@echo foo')"
'@echo' is not recognized as an internal or external command,
operable program or batch file.

C:>python -c "import os;os.system('@echo foo')"
foo

C:>python -c "import os;os.system('@echo foo')"
'@echo' is not recognized as an internal or external command,
operable program or batch file.
=end

#3 Updated by Jon Forums about 3 years ago

=begin
and...

C:>lua -e "os.execute(\"@echo foo\")"
foo

C:>python -c "import os;os.system(\"@echo foo\")"
foo

=end

#4 Updated by Motohiro KOSAKI about 3 years ago

=begin
Hi Jon,

Thanks for good demonstration. It encourage to me very much.
But #3 is a bit misleading. ^ was removed when command line parsing (ie python interpreter invoking) phase. therefore system() haven't seen .

Example, Please see following one liner.

c:\ruby\trunk\build>python -c "print \"@echo foo\""
@echo foo

=end

#5 Updated by Motohiro KOSAKI about 3 years ago

  • Status changed from Open to Rejected

=begin
I tried to change this behavir by r30987. but it made a regression.

example, r30987 broke testprocess.rb#testpopen_shell(). because
IO.popen(%[#{bat.dump} "foo 'bar'"]) pass a follwoing string to cmd.exe.

"path with space/bat test.bat" "foo 'bar'"

But cmd.exe can't parse it. IOW, current ruby's system() has slightly different parser against cmd.exe and some tests depend on it.

So, sadly, we can't break backward compatibility. Let's reject this ticket.
=end

Also available in: Atom PDF