From: reddy.rushyanth@... Date: 2018-05-17T09:27:36+00:00 Subject: [ruby-core:87124] [Ruby trunk Bug#14765] Arguments passed to Open3.popen3() are not interpreted as wildcards Issue #14765 has been updated by Rushyanth (Rushyanth reddy). Suppose I have a variable ``` x = "abc"``` I need to cat a file ```abc.yml``` I write ``` Open3.popen3("cat #{x}.yml")``` --------------------- (1) This will lead to Command Injection warning. So we need to pass the arguments seperately like ``` Open3.popen3("cat", x+".yml")``` ------------------- (2) The second type will not lead to command Injection warning and both cases 1 and 2 work fine But If I need to retrieve data of many files not just a single file. Then I need to write ``` Open3.popen3("cat *.yml")``` -------- (1) or ``` Open3.popen3("cat", "*.yml")``` ------ (2) The 1st case works fine but the second case fails . Because in second case ```popen3``` is interpreting its second argument ```*.yml``` as a file name . But ```*``` should actually be interpreted as regular expression character where it retrieves all the file names ending in ```.yml``` ---------------------------------------- Bug #14765: Arguments passed to Open3.popen3() are not interpreted as wildcards https://bugs.ruby-lang.org/issues/14765#change-72109 * Author: Rushyanth (Rushyanth reddy) * Status: Rejected * Priority: Normal * Assignee: * Target version: * ruby -v: 2.3.1 * Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN ---------------------------------------- In console when we write ```ruby stdin, stdout, stderr, wait_thr = Open3.popen4("cat .*.yml") stdout.readlines ``` All the files with names starting with `.` and ending in `.yml` are shown But when we do ```ruby stdin, stdout, stderr, wait_thr = Open3.popen4("cat", ".*.yml") stdout.readlines ``` It returns an empty array `stderr.readlines` says `["cat: .*.yml: No such file or directory\n"]` Because it is interpreting the string arguments as it is and looking for a file with name `.*.yml` and not interpreting as in the first case. -- https://bugs.ruby-lang.org/ Unsubscribe: