[holy ruby programmers batman!] Stupid string tricks

Avdi Grimm avdi at avdi.org
Sun Dec 23 14:10:12 EST 2007

On Dec 23, 2007 1:54 PM, Giles Bowkett <gilesb at gmail.com> wrote:
> > # notify me when my object is destroyed (on a Mac)
> > ObjectSpace.define_finalizer(my_obj, proc { "Goodbye cruel world!" |
> > 'growlnotify' })
> Just to play devil's advocate, I think all of this stuff can actually
> be achieved with string interpolation and system calls

To play angel's advocate:  The trouble with string interpolation and
backticks/system is that a) some commands expect their input to either
be on STDIN or in a real file; and b) you may have escaping issues;
and c) if nothing else, eventually you'll hit your OS' command line
length limit.

(Aside: this makes me think that another useful utility might be one
that makes it trivially easy to convert a string into a temporary file
which contains the string...)

But that's just for the sake of argument; I haven't actually found
this stunt to be of enormous utility yet.


More information about the Utilitybelt-tinkering mailing list