From: "Dan0042 (Daniel DeLorme)" Date: 2022-07-05T19:51:05+00:00 Subject: [ruby-core:109146] [Ruby master Bug#18896] Shellwords.escape(nil) returns "empty" string 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) #=> "\\#\\" ``` 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: