[ruby-core:77957] [Ruby trunk Bug#10055] Shellwords.shellsplit() does not match POSIX sh behavior for backslashes within double-quoted strings

From: knu@...
Date: 2016-11-05 05:00:42 UTC
List: ruby-core #77957
Issue #10055 has been updated by Akinori MUSHA.


That is correct!  I've fixed the implementation to conform to the standard.

----------------------------------------
Bug #10055: Shellwords.shellsplit() does not match POSIX sh behavior for backslashes within double-quoted strings
https://bugs.ruby-lang.org/issues/10055#change-61284

* Author: Charles Duffy
* Status: Closed
* Priority: Normal
* Assignee: Akinori MUSHA
* ruby -v: ruby 2.2.0dev (2014-07-18 trunk 46855) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
In POSIX sh, the following commands are identical:

~~~
printf '%s\n' hello world
printf "%s\n" hello world
~~~

However, Shellwords.shellsplit() parses them differently:

~~~
head :001 > require 'shellwords'
 => true
head :002 > Shellwords.shellsplit(%q|printf "%s\\n"|)
 => ["printf", "%sn"]
head :003 > Shellwords.shellsplit(%q|printf '%s\\n'|)
 => ["printf", "%s\\n"]
~~~

The documentation for the shellwords module claims that its parser is compatible with Bourne; however, it does not match either this 1970s-era shell language or modern POSIX sh (which is the actual specification used for /bin/sh on modern systems, and incompatible in some respects with original Bourne), both of which preserve backslashes in this context.



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

Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next