From: Alan Davies Date: 2003-09-23T19:53:25+09:00 Subject: Re: Dir.foreach not with patterns? ts wrote: >>>>>>"A" == Alan Davies writes: > > > A> I'm pretty sure you can't have filenames with \n in them, and that > A> pattern wouldn't match them anyway. > > Then test it with a real OS :-) Personally I can't stand linux/unix, but each to his own, as they say. > > svg% ls -a > / ../ > svg% > > svg% ruby -e 'Dir.mkdir "aa\n.."' > svg% > > svg% ls -a > / ../ aa?../ > svg% > > svg% ruby -e 'Dir.foreach(".") {|d| p d}' > "." > ".." > "aa\n.." > svg% > > svg% ruby -e 'Dir.foreach(".") {|d| next if d =~ /^\.\.?$/; p d}' > svg% > > > > Guy Decoux > > Filenames with \n in them is the most ridiculous thing I've ever heard. I take it the regexp should be /\A\.\.?\z/ then? Alan.