Project

General

Profile

Bug #4396

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

Added by kosaki (Motohiro KOSAKI) over 6 years ago. Updated over 6 years ago.

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

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 allClosed2011-02-13

History

#1 Updated by kosaki (Motohiro KOSAKI) over 6 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 jonforums (Jon Forums) over 6 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 jonforums (Jon Forums) over 6 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 kosaki (Motohiro KOSAKI) over 6 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 [ruby-core:35402] Updated by kosaki (Motohiro KOSAKI) over 6 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 test_process.rb#test_popen_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