sys_cmd 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 49cb2627e0466057f34aab03f9b30a963bf200b9
4
- data.tar.gz: ffe64d2249bfc28fa85d9dfab03a017970045047
3
+ metadata.gz: 9c02b5ad342cfe1834b58e1d12569592a8172c20
4
+ data.tar.gz: ce155ac1c8ce48cdc995dd4eb076de4fb7018d5f
5
5
  SHA512:
6
- metadata.gz: 9789c5e5c29b8e56ab83a855fc3d04924e11dc2d854cf70f28ad41cb418ba2d734d9fbff5bbac3dafc2d204b0a1663228805d02901c25335b1b2cb6e22d60e69
7
- data.tar.gz: be19e8ca84e0b031d3972d73f05dfad0804c4328c7233aae1b74cf16cbd7912d0eb0af4f26161903bcc60eb104f7aba64a4e44966dca6860e24a54804b7ec05c
6
+ metadata.gz: e9ab2af6ca3fabe134f1898f8a1898f92ece5dfd0172fcf5b1a44a548ccd75581b75b86866b4305c523c85bfc44369ddfbba5ecff9f093fbf952ac5dd51e86a5
7
+ data.tar.gz: f1b283a4bb2b80ae33d4abf3f222ac4586f59da1e6c5b176e8e94eb6f682d5bba92f508b97f8e7e1536f283b163265b35e41ac419439574f3df7a33def02d8fe
@@ -78,6 +78,9 @@ module SysCmd
78
78
  else
79
79
  option = option.dup
80
80
  end
81
+ if @shell.requires_escaping?(option)
82
+ option = @shell.escape_value(option)
83
+ end
81
84
  option << ' ' << @shell.escape_value(value) if value
82
85
  option << @shell.escape_value(options[:join_value]) if options[:join_value]
83
86
  option << '=' << @shell.escape_value(options[:equal_value]) if options[:equal_value]
@@ -181,7 +184,11 @@ module SysCmd
181
184
  # are note interpreted by a shell in that case.
182
185
  def argument(value, options = {})
183
186
  return unless @shell.applicable?(options)
184
- @command << ' ' << value.to_s
187
+ value = value.to_s
188
+ if @shell.requires_escaping?(value)
189
+ value = @shell.escape_value(value)
190
+ end
191
+ @command << ' ' << value
185
192
  @last_arg = :argument
186
193
  end
187
194
 
@@ -372,6 +379,10 @@ module SysCmd
372
379
  end
373
380
  end
374
381
 
382
+ def self.requires_escaping?(text, options = {})
383
+ /[\s\"\']/ =~ text
384
+ end
385
+
375
386
  def self.split(text, options = {})
376
387
  case os_type(options)
377
388
  when :windows
@@ -433,6 +444,10 @@ module SysCmd
433
444
  SysCmd.escape(text, os: @type)
434
445
  end
435
446
 
447
+ def requires_escaping?(text)
448
+ SysCmd.requires_escaping?(text, os: @type)
449
+ end
450
+
436
451
  def split(text)
437
452
  SysCmd.split(text, os: @type)
438
453
  end
@@ -1,3 +1,3 @@
1
1
  module SysCmd
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sys_cmd
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Javier Goizueta
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-07-21 00:00:00.000000000 Z
11
+ date: 2015-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: os