Bug #4396
closed
windows commands starting with "@" should run at all even though command string is quoted by `"'.
Added by kosaki (Motohiro KOSAKI) over 13 years ago.
Updated over 13 years ago.
Description
=begin
This issue
C test program.¶
main()
{
system(""@echo foo"");
}
=> foo
Ruby test program.¶
ruby -e 'p system(""@echo foo"")'
=> nil
=end
=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
=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
=begin
and...
C:>lua -e "os.execute("^@echo foo")"
foo
C:>python -c "import os;os.system("^@echo foo")"
foo
=end
=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
- 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
Like0
Like0Like0Like0Like0Like0