shellwords 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/shellwords.rb +18 -3
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ccc635a3993667e34ee88b0e3122d3aa1f67776c36cc69fcc68288e85cfe6f2a
|
4
|
+
data.tar.gz: b64c7a5c30cc77284e49fa4cc8663369e3d90cd32b782443f1b5a955346f533a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b81ed293a4dd49fe6cf0be82b1ad0d98efdecc3a549c13451ac638fdf546e067c5a556677fc4a2d3601772e4a9a03fba62ce29b786127f473b9d1b936175b19
|
7
|
+
data.tar.gz: 1d91518f6df2b52b629bad0b7659006376e6667a4c2dc5c406649a221c65fbeffd5087146ac4fa58f9af9789ecf8119ae86ba32467061c019a61d8b8486f24cd
|
data/lib/shellwords.rb
CHANGED
@@ -65,7 +65,7 @@
|
|
65
65
|
|
66
66
|
module Shellwords
|
67
67
|
# The version number string.
|
68
|
-
VERSION = "0.2.
|
68
|
+
VERSION = "0.2.2"
|
69
69
|
|
70
70
|
# Splits a string into an array of tokens in the same way the UNIX
|
71
71
|
# Bourne shell does.
|
@@ -73,6 +73,9 @@ module Shellwords
|
|
73
73
|
# argv = Shellwords.split('here are "two words"')
|
74
74
|
# argv #=> ["here", "are", "two words"]
|
75
75
|
#
|
76
|
+
# +line+ must not contain NUL characters because of nature of
|
77
|
+
# +exec+ system call.
|
78
|
+
#
|
76
79
|
# Note, however, that this is not a command line parser. Shell
|
77
80
|
# metacharacters except for the single and double quotes and
|
78
81
|
# backslash are not treated as such.
|
@@ -87,9 +90,14 @@ module Shellwords
|
|
87
90
|
def shellsplit(line)
|
88
91
|
words = []
|
89
92
|
field = String.new
|
90
|
-
line.scan(/\G\s*(?>([^\s\\\'\"]+)|'([^\']*)'|"((?:[^\"\\]
|
93
|
+
line.scan(/\G\s*(?>([^\0\s\\\'\"]+)|'([^\0\']*)'|"((?:[^\0\"\\]|\\[^\0])*)"|(\\[^\0]?)|(\S))(\s|\z)?/m) do
|
91
94
|
|word, sq, dq, esc, garbage, sep|
|
92
|
-
|
95
|
+
if garbage
|
96
|
+
b = $~.begin(0)
|
97
|
+
line = $~[0]
|
98
|
+
line = "..." + line if b > 0
|
99
|
+
raise ArgumentError, "#{garbage == "\0" ? 'Nul character' : 'Unmatched quote'} at #{b}: #{line}"
|
100
|
+
end
|
93
101
|
# 2.2.3 Double-Quotes:
|
94
102
|
#
|
95
103
|
# The <backslash> shall retain its special meaning as an
|
@@ -118,6 +126,9 @@ module Shellwords
|
|
118
126
|
# command line. +str+ can be a non-string object that responds to
|
119
127
|
# +to_s+.
|
120
128
|
#
|
129
|
+
# +str+ must not contain NUL characters because of nature of +exec+
|
130
|
+
# system call.
|
131
|
+
#
|
121
132
|
# Note that a resulted string should be used unquoted and is not
|
122
133
|
# intended for use in double quotes nor in single quotes.
|
123
134
|
#
|
@@ -150,6 +161,9 @@ module Shellwords
|
|
150
161
|
# An empty argument will be skipped, so return empty quotes.
|
151
162
|
return "''".dup if str.empty?
|
152
163
|
|
164
|
+
# Shellwords cannot contain NUL characters.
|
165
|
+
raise ArgumentError, "NUL character" if str.index("\0")
|
166
|
+
|
153
167
|
str = str.dup
|
154
168
|
|
155
169
|
# Treat multibyte characters as is. It is the caller's responsibility
|
@@ -175,6 +189,7 @@ module Shellwords
|
|
175
189
|
# All elements are joined into a single string with fields separated by a
|
176
190
|
# space, where each element is escaped for the Bourne shell and stringified
|
177
191
|
# using +to_s+.
|
192
|
+
# See also Shellwords.shellescape.
|
178
193
|
#
|
179
194
|
# ary = ["There's", "a", "time", "and", "place", "for", "everything"]
|
180
195
|
# argv = Shellwords.join(ary)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shellwords
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Akinori MUSHA
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Manipulates strings with word parsing rules of UNIX Bourne shell.
|
14
14
|
email:
|
@@ -34,7 +34,7 @@ licenses:
|
|
34
34
|
metadata:
|
35
35
|
homepage_uri: https://github.com/ruby/shellwords
|
36
36
|
source_code_uri: https://github.com/ruby/shellwords
|
37
|
-
post_install_message:
|
37
|
+
post_install_message:
|
38
38
|
rdoc_options: []
|
39
39
|
require_paths:
|
40
40
|
- lib
|
@@ -50,7 +50,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
50
50
|
version: '0'
|
51
51
|
requirements: []
|
52
52
|
rubygems_version: 3.5.11
|
53
|
-
signing_key:
|
53
|
+
signing_key:
|
54
54
|
specification_version: 4
|
55
55
|
summary: Manipulates strings with word parsing rules of UNIX Bourne shell.
|
56
56
|
test_files: []
|