Shellwords.escape(nil) returns "empty" string
Mistakenly calling Shellwords.escape with nil as parameter had this result:
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.
# gem list shellwords *** LOCAL GEMS *** shellwords (default: 0.1.0) #
Updated by Dan0042 (Daniel DeLorme) about 1 month ago
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(Object.new) #=> "\\#\\<Object:0x00007f01ae28c3a8\\>"
At this point, changing the API in such a backward-incompatible way would cause more problems than benefit.