Robert Klemme <bob.news / gmx.net> wrote: > > > > Hm - I was trying to avoid an extraneous 'split', since cols always > > requires one. Maybe check if the first argument is a string and split on > > that, otherwise split on space. > > I'd find it more clean if it was not a parameter to cols but an extra > operation before. You can leave it as it is with two changes if you just > add method cols to Array (or enumerable). Then you can use the old > behavior (i.e. implicit split by white space) and additionally you can use > String#split to do the splitting. Good point - and it's the nicely polymorphic way to do it too. I'll have to see if the array/string idea can extend to other methds too. A third option is to simply use -F, though if you're writing a one-liner going back and adding it in if you realise you need it at the time you're typing in 'cols' will be a pain. > > But how will that let us pass options to the ruby interpreter? > > Which options do you need to pass on? If it's not too esoteric, you might > be able to set them via global variables. The main ones I've found useful in practice are -i and -rwhatever (ideally I'd like an interpreter switch for the $_.instance_eval loop, parallel to -n and -p, but when I RCRd it it wasn't too popular). You're right, they probably could be set via globals, which would save us the extra process spawn. I might think up some options that make sense for rbx but not for ruby too, in which case optparse is definitely the way to go. martin