shellwords 0.2.0 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e221d4a4dfd65b01ce8fefcff226e75c20a50e4c80a8df1c4598b312bad28799
4
- data.tar.gz: 22a1c6b889c1cbc8cb18b74804c92eb5697ef85c046c03e2cd3a8037c77c8992
3
+ metadata.gz: ccc635a3993667e34ee88b0e3122d3aa1f67776c36cc69fcc68288e85cfe6f2a
4
+ data.tar.gz: b64c7a5c30cc77284e49fa4cc8663369e3d90cd32b782443f1b5a955346f533a
5
5
  SHA512:
6
- metadata.gz: f76872d1bdcc53a155dbab7cdc356ad85c570f8d67c2b82c22d148581bd5ec1072bdc7d6a22aa1f5625640bfff900d4906569a66b866854523cf82807169992c
7
- data.tar.gz: 85f44a10ae9aece86aa1890588882cddbf1d54d709a6456d766c3f53511ee781c9ac0b84bc6cb784ea195e1c5ca9a56c2f6f730e4c6abf780b6585b6f222464f
6
+ metadata.gz: 8b81ed293a4dd49fe6cf0be82b1ad0d98efdecc3a549c13451ac638fdf546e067c5a556677fc4a2d3601772e4a9a03fba62ce29b786127f473b9d1b936175b19
7
+ data.tar.gz: 1d91518f6df2b52b629bad0b7659006376e6667a4c2dc5c406649a221c65fbeffd5087146ac4fa58f9af9789ecf8119ae86ba32467061c019a61d8b8486f24cd
data/.builtins.rb ADDED
@@ -0,0 +1,4 @@
1
+ # :stopdoc:
2
+ class Array end
3
+ class String end
4
+ # :startdoc:
data/.document ADDED
@@ -0,0 +1,4 @@
1
+ LICENSE.txt
2
+ README.md
3
+ .builtins.rb
4
+ lib/
data/.rdoc_options ADDED
@@ -0,0 +1,2 @@
1
+ ---
2
+ main_page: README.md
@@ -4,10 +4,10 @@ Redistribution and use in source and binary forms, with or without
4
4
  modification, are permitted provided that the following conditions
5
5
  are met:
6
6
  1. Redistributions of source code must retain the above copyright
7
- notice, this list of conditions and the following disclaimer.
7
+ notice, this list of conditions and the following disclaimer.
8
8
  2. Redistributions in binary form must reproduce the above copyright
9
- notice, this list of conditions and the following disclaimer in the
10
- documentation and/or other materials provided with the distribution.
9
+ notice, this list of conditions and the following disclaimer in the
10
+ documentation and/or other materials provided with the distribution.
11
11
 
12
12
  THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
13
13
  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
data/COPYING ADDED
@@ -0,0 +1,56 @@
1
+ Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
2
+ You can redistribute it and/or modify it under either the terms of the
3
+ 2-clause BSDL (see the file BSDL), or the conditions below:
4
+
5
+ 1. You may make and give away verbatim copies of the source form of the
6
+ software without restriction, provided that you duplicate all of the
7
+ original copyright notices and associated disclaimers.
8
+
9
+ 2. You may modify your copy of the software in any way, provided that
10
+ you do at least ONE of the following:
11
+
12
+ a. place your modifications in the Public Domain or otherwise
13
+ make them Freely Available, such as by posting said
14
+ modifications to Usenet or an equivalent medium, or by allowing
15
+ the author to include your modifications in the software.
16
+
17
+ b. use the modified software only within your corporation or
18
+ organization.
19
+
20
+ c. give non-standard binaries non-standard names, with
21
+ instructions on where to get the original software distribution.
22
+
23
+ d. make other distribution arrangements with the author.
24
+
25
+ 3. You may distribute the software in object code or binary form,
26
+ provided that you do at least ONE of the following:
27
+
28
+ a. distribute the binaries and library files of the software,
29
+ together with instructions (in the manual page or equivalent)
30
+ on where to get the original distribution.
31
+
32
+ b. accompany the distribution with the machine-readable source of
33
+ the software.
34
+
35
+ c. give non-standard binaries non-standard names, with
36
+ instructions on where to get the original software distribution.
37
+
38
+ d. make other distribution arrangements with the author.
39
+
40
+ 4. You may modify and include the part of the software into any other
41
+ software (possibly commercial). But some files in the distribution
42
+ are not written by the author, so that they are not under these terms.
43
+
44
+ For the list of those files and their copying conditions, see the
45
+ file LEGAL.
46
+
47
+ 5. The scripts and library files supplied as input to or produced as
48
+ output from the software do not automatically fall under the
49
+ copyright of the software, but belong to whomever generated them,
50
+ and may be sold commercially, and may be aggregated with this
51
+ software.
52
+
53
+ 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
54
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
55
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
56
+ PURPOSE.
data/README.md CHANGED
@@ -3,11 +3,11 @@
3
3
  This module manipulates strings according to the word parsing rules
4
4
  of the UNIX Bourne shell.
5
5
 
6
- The shellwords() function was originally a port of shellwords.pl,
7
- but modified to conform to the Shell & Utilities volume of the IEEE
8
- Std 1003.1-2008, 2016 Edition [1].
6
+ The `shellwords()` function was originally a port of shellwords.pl,
7
+ but modified to conform to [the Shell & Utilities volume of the IEEE
8
+ Std 1003.1-2008, 2016 Edition].
9
9
 
10
- [1] [IEEE Std 1003.1-2008, 2016 Edition, the Shell & Utilities volume](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/contents.html)
10
+ [the Shell & Utilities volume of the IEEE Std 1003.1-2008, 2016 Edition]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/contents.html
11
11
 
12
12
  ## Installation
13
13
 
@@ -43,4 +43,3 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
43
43
  ## Contributing
44
44
 
45
45
  Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/shellwords.
46
-
data/lib/shellwords.rb CHANGED
@@ -5,9 +5,9 @@
5
5
  # This module manipulates strings according to the word parsing rules
6
6
  # of the UNIX Bourne shell.
7
7
  #
8
- # The shellwords() function was originally a port of shellwords.pl,
9
- # but modified to conform to the Shell & Utilities volume of the IEEE
10
- # Std 1003.1-2008, 2016 Edition [1].
8
+ # The <tt>shellwords()</tt> function was originally a port of shellwords.pl, but
9
+ # modified to conform to {the Shell & Utilities volume of the IEEE Std 1003.1-2008, 2016
10
+ # Edition}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/contents.html]
11
11
  #
12
12
  # === Usage
13
13
  #
@@ -62,13 +62,10 @@
62
62
  #
63
63
  # === Contact
64
64
  # * Akinori MUSHA <knu@iDaemons.org> (current maintainer)
65
- #
66
- # === Resources
67
- #
68
- # 1: {IEEE Std 1003.1-2008, 2016 Edition, the Shell & Utilities volume}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/contents.html]
69
65
 
70
66
  module Shellwords
71
- VERSION = "0.2.0"
67
+ # The version number string.
68
+ VERSION = "0.2.2"
72
69
 
73
70
  # Splits a string into an array of tokens in the same way the UNIX
74
71
  # Bourne shell does.
@@ -76,6 +73,9 @@ module Shellwords
76
73
  # argv = Shellwords.split('here are "two words"')
77
74
  # argv #=> ["here", "are", "two words"]
78
75
  #
76
+ # +line+ must not contain NUL characters because of nature of
77
+ # +exec+ system call.
78
+ #
79
79
  # Note, however, that this is not a command line parser. Shell
80
80
  # metacharacters except for the single and double quotes and
81
81
  # backslash are not treated as such.
@@ -90,9 +90,14 @@ module Shellwords
90
90
  def shellsplit(line)
91
91
  words = []
92
92
  field = String.new
93
- line.scan(/\G\s*(?>([^\s\\\'\"]+)|'([^\']*)'|"((?:[^\"\\]|\\.)*)"|(\\.?)|(\S))(\s|\z)?/m) do
93
+ line.scan(/\G\s*(?>([^\0\s\\\'\"]+)|'([^\0\']*)'|"((?:[^\0\"\\]|\\[^\0])*)"|(\\[^\0]?)|(\S))(\s|\z)?/m) do
94
94
  |word, sq, dq, esc, garbage, sep|
95
- raise ArgumentError, "Unmatched quote: #{line.inspect}" if garbage
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
96
101
  # 2.2.3 Double-Quotes:
97
102
  #
98
103
  # The <backslash> shall retain its special meaning as an
@@ -121,6 +126,9 @@ module Shellwords
121
126
  # command line. +str+ can be a non-string object that responds to
122
127
  # +to_s+.
123
128
  #
129
+ # +str+ must not contain NUL characters because of nature of +exec+
130
+ # system call.
131
+ #
124
132
  # Note that a resulted string should be used unquoted and is not
125
133
  # intended for use in double quotes nor in single quotes.
126
134
  #
@@ -153,6 +161,9 @@ module Shellwords
153
161
  # An empty argument will be skipped, so return empty quotes.
154
162
  return "''".dup if str.empty?
155
163
 
164
+ # Shellwords cannot contain NUL characters.
165
+ raise ArgumentError, "NUL character" if str.index("\0")
166
+
156
167
  str = str.dup
157
168
 
158
169
  # Treat multibyte characters as is. It is the caller's responsibility
@@ -178,6 +189,7 @@ module Shellwords
178
189
  # All elements are joined into a single string with fields separated by a
179
190
  # space, where each element is escaped for the Bourne shell and stringified
180
191
  # using +to_s+.
192
+ # See also Shellwords.shellescape.
181
193
  #
182
194
  # ary = ["There's", "a", "time", "and", "place", "for", "everything"]
183
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.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akinori MUSHA
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-11-06 00:00:00.000000000 Z
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:
@@ -17,18 +17,16 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
- - ".github/CODEOWNERS"
21
- - ".github/dependabot.yml"
22
- - ".github/workflows/test.yml"
23
- - ".gitignore"
20
+ - ".builtins.rb"
21
+ - ".document"
22
+ - ".rdoc_options"
23
+ - BSDL
24
+ - COPYING
24
25
  - Gemfile
25
- - LICENSE.txt
26
26
  - README.md
27
- - Rakefile
28
27
  - bin/console
29
28
  - bin/setup
30
29
  - lib/shellwords.rb
31
- - shellwords.gemspec
32
30
  homepage: https://github.com/ruby/shellwords
33
31
  licenses:
34
32
  - Ruby
@@ -51,7 +49,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
51
49
  - !ruby/object:Gem::Version
52
50
  version: '0'
53
51
  requirements: []
54
- rubygems_version: 3.5.0.dev
52
+ rubygems_version: 3.5.11
55
53
  signing_key:
56
54
  specification_version: 4
57
55
  summary: Manipulates strings with word parsing rules of UNIX Bourne shell.
data/.github/CODEOWNERS DELETED
@@ -1 +0,0 @@
1
- * @knu
@@ -1,6 +0,0 @@
1
- version: 2
2
- updates:
3
- - package-ecosystem: 'github-actions'
4
- directory: '/'
5
- schedule:
6
- interval: 'weekly'
@@ -1,31 +0,0 @@
1
- name: test
2
-
3
- on: [push, pull_request]
4
-
5
- jobs:
6
- ruby-versions:
7
- uses: ruby/actions/.github/workflows/ruby_versions.yml@master
8
- with:
9
- min_version: 2.5
10
-
11
- test:
12
- needs: ruby-versions
13
- name: build (${{ matrix.ruby }} / ${{ matrix.os }})
14
- strategy:
15
- matrix:
16
- ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
17
- os: [ ubuntu-latest, macos-latest, windows-latest ]
18
- exclude:
19
- - { os: windows-latest, ruby: truffleruby-head }
20
- - { os: windows-latest, ruby: truffleruby }
21
- runs-on: ${{ matrix.os }}
22
- steps:
23
- - uses: actions/checkout@v4
24
- - name: Set up Ruby
25
- uses: ruby/setup-ruby@v1
26
- with:
27
- ruby-version: ${{ matrix.ruby }}
28
- - name: Install dependencies
29
- run: bundle install
30
- - name: Run test
31
- run: rake test
data/.gitignore DELETED
@@ -1,9 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
- Gemfile.lock
data/Rakefile DELETED
@@ -1,10 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rake/testtask"
3
-
4
- Rake::TestTask.new(:test) do |t|
5
- t.libs << "test"
6
- t.libs << "lib"
7
- t.test_files = FileList["test/**/test_*.rb"]
8
- end
9
-
10
- task :default => :test
data/shellwords.gemspec DELETED
@@ -1,30 +0,0 @@
1
- name = File.basename(__FILE__, ".gemspec")
2
- version = ["lib", Array.new(name.count("-")+1).join("/")].find do |dir|
3
- break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
4
- /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
5
- end rescue nil
6
- end
7
-
8
-
9
- Gem::Specification.new do |spec|
10
- spec.name = name
11
- spec.version = version
12
- spec.authors = ["Akinori MUSHA"]
13
- spec.email = ["knu@idaemons.org"]
14
-
15
- spec.summary = %q{Manipulates strings with word parsing rules of UNIX Bourne shell.}
16
- spec.description = %q{Manipulates strings with word parsing rules of UNIX Bourne shell.}
17
- spec.homepage = "https://github.com/ruby/shellwords"
18
- spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
19
- spec.licenses = ["Ruby", "BSD-2-Clause"]
20
-
21
- spec.metadata["homepage_uri"] = spec.homepage
22
- spec.metadata["source_code_uri"] = spec.homepage
23
-
24
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
25
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
- end
27
- spec.bindir = "exe"
28
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
- spec.require_paths = ["lib"]
30
- end