[#109207] [Ruby master Feature#18915] New error class: NotImplementedYetError or scope change for NotImplementedYet — Quintasan <noreply@...>
Issue #18915 has been reported by Quintasan (Michał Zając).
18 messages
2022/07/14
[ruby-core:109146] [Ruby master Bug#18896] Shellwords.escape(nil) returns "empty" string
From:
"Dan0042 (Daniel DeLorme)" <noreply@...>
Date:
2022-07-05 19:51:05 UTC
List:
ruby-core #109146
Issue #18896 has been updated by Dan0042 (Daniel DeLorme).
`Shellwords.escape` just converts the argument to a string before shell-escaping it, so in this context nil is equivalent to ""
```
Shellwords.escape("") #=> "''"
Shellwords.escape(42) #=> "42"
Shellwords.escape(Objct.new) #=> "\\#\\<Object:0x00007f01ae28c3a8\\>"
```
At this point, changing the API in such a backward-incompatible way would cause more problems than benefit.
----------------------------------------
Bug #18896: Shellwords.escape(nil) returns "empty" string
https://bugs.ruby-lang.org/issues/18896#change-98286
* Author: hspem (Per-Erik Martin)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [powerpc-aix7.1.0]
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
Mistakenly calling Shellwords.escape with nil as parameter had this result:
``` ruby
irb(main):002:0> Shellwords.escape(nil)
=> "''"
```
This is not helpful and resulted a hard-to-find bug when a script proceeded to use an empty string where it shouldn't be possible. nil is not a string and escape should raise an exception instead.
Shellwords version:
``` shell
# gem list shellwords
*** LOCAL GEMS ***
shellwords (default: 0.1.0)
#
```
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>