[#64517] Fw: Re: Ruby and Rails to become Apache Incubator Project — Tetsuya Kitahata <kitahata@99.alumni.u-tokyo.ac.jp>

What do you think? >> Ruby developers

13 messages 2014/08/23

[#64615] [ruby-trunk - Feature #10181] [Open] New method File.openat() — oss-ruby-lang@...

Issue #10181 has been reported by Technorama Ltd..

10 messages 2014/08/28
[#64616] Re: [ruby-trunk - Feature #10181] [Open] New method File.openat() — Eric Wong <normalperson@...> 2014/08/28

I like this feature.

[#64671] Fwd: [ruby-changes:35240] normal:r47322 (trunk): symbol.c (rb_sym2id): do not return garbage object — SASADA Koichi <ko1@...>

Why this fix solve your problem?

9 messages 2014/08/30
[#64672] Re: Fwd: [ruby-changes:35240] normal:r47322 (trunk): symbol.c (rb_sym2id): do not return garbage object — SASADA Koichi <ko1@...> 2014/08/30

(2014/08/30 8:50), SASADA Koichi wrote:

[ruby-core:64339] [ruby-trunk - Bug #10128] [Open] Quoting problem for arguments of Kernel.system, Kernel.exec on Windows

From: hunter_spawn@...
Date: 2014-08-12 16:18:31 UTC
List: ruby-core #64339
Issue #10128 has been reported by Maxime Lapointe.

----------------------------------------
Bug #10128: Quoting problem for arguments of Kernel.system, Kernel.exec on Windows
https://bugs.ruby-lang.org/issues/10128

* Author: Maxime Lapointe
* Status: Open
* Priority: Normal
* Assignee: cruby-windows
* Category: platform/windows
* Target version: 
* ruby -v: ruby 2.0.0p481 (2014-05-08) [x64-mingw32]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
On Windows, the methods that call shell commands and receive the parameters individually sometimes do not wrap the parameters sent in quotes. 
This results in Windows either splitting the parameter in 2 parameters or, worse, splitting the command in 2 commands.

I joined the file *puts_first.bat*, which simply outputs the first argument it received. When the parameter received was wrapped by ruby, you will see quotes, it's normal. Just run a irb from from the directory containing that file.

Lines that don't work properly (Using Kernel.exec will do the same thing):

    # these write *hello*, then says 'world' is not recognized as an internal or external command
    Kernel.system 'puts_first.bat', 'hello&world'
    Kernel.system 'puts_first.bat', 'hello|world'

    # these write *hello*
    Kernel.system 'puts_first.bat', 'hello,world'
    Kernel.system 'puts_first.bat', 'hello;world'
    Kernel.system 'puts_first.bat', 'hello<world'

    # this writes *hello* in the file world
    Kernel.system 'puts_first.bat', 'hello>world'

    # this writes *helloworld* without the ^
    Kernel.system 'puts_first.bat', 'hello^world'

If we add a space anywhere in the above hello world strings, it will work as expected because ruby wraps the parameter if it finds a space.


    # Ruby does try to wrap if it finds a double quote, but it escapes double quotes incorrectly:
    # this writes *"hello\"world"*, double quotes should be escaped by putting 2 of them, so we should see: *"hello""world"*
    Kernel.system 'puts_first.bat', 'hello"world'

    # adding a space show the problem in action, this writes *"hello\"*
    Kernel.system 'puts_first.bat', 'hello" world'


As a side note, the single quote is not special in Windows, so there is no need to wrap this (but I don't think it's a problem):
    
    # this writes *"hello'world"*
    Kernel.system 'puts_first.bat', "hello'world"

This bug also happens in 1.9.3, do you think this be backported?

Unless I did a mistake, this should be all of the problematic characters, I tested with every printable ascii characters.

Thank you

---Files--------------------------------
puts_first.bat (18 Bytes)


-- 
https://bugs.ruby-lang.org/

In This Thread

Prev Next