From: John Carter Date: 2008-08-13T05:55:51+09:00 Subject: File redirects in Ruby? Was Re: Sigh! I'm depressed. Debian vs Rubyand the backtick and subshells On Tue, 12 Aug 2008, Phlip wrote: >>> build@ws1419:~/AutomatedBuild/test$ ruby -e 'system("ls >>> NOFILEWITHTHISNAME&>foo")' > > Magicloud Magiclouds wrote: > >> I am using Debian sid, which sh is bash. >> And, in fact, I hate ruby's way of system call. Ugly and hard to use and >> stupid hardcoded. > > The choice of `` is deliberate. It's to inspire you to get off your lazy butt > and learn the Ruby-internal way to do something, such as Pathname.glob. > There's always a way to avoid a shell command... There are two reasons I use ``. 1) Quick and easy. Much quicker to type ` ` than system " " 2) When I want the output of a program as a string, much easier to type `blah` than IO.read("|blah") Whilst shell globbing has some shorthandedness about it, the main reason is are file redirects. > &> >2&1 I'm quite happy to override `` with that trick someone mentioned above if it grants me deterministic behaviour between client boxes. (I don't care if its the wrong behaviour, so long as it's the _same_ behaviour!) I often use Dir["bla*"] and glob with glee. Anyone have a short and easy Ruby way of doing file redirects? John Carter Phone : (64)(3) 358 6639 Tait Electronics Fax : (64)(3) 359 4632 PO Box 1645 Christchurch Email : john.carter@tait.co.nz New Zealand