Re: should I be able to write to filenames with a pipe in them?
Roger Pack <[email protected]>
| Newsgroups | gmane.comp.lang.ruby.general |
|---|---|
| Message-ID | <CAL1QdWeHXH_YNQAphz6DBT1pT_44N=-fnCptfVC9yyno66gpFA@mail.gmail.com> |
On Wed, Oct 24, 2018 at 3:37 PM Eric Wong <[email protected]> wrote: > > Roger Pack <[email protected]> wrote: > > this code: > > > > a = "|AB|" > > File.write(a, a) > > That spawns a shell in older Rubies and was a security problem > last year or so. Ahh it was like a magic filename of some kind. Gotcha. Thanks! > > Filenames with pipes in them are valid in linux. Is there something > > I'm missing here or is this a bug do you think? > > Using File.open instead works for all versions of Ruby: > > a = "|AB|" > File.open(a, 'w') { |fp| fp.write(a) } Thanks! Unsubscribe: <mailto:[email protected]?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>