Re: r4 - the simplest ruby pre-processor



On Mon, 12 Sep 2005, Christian Neukirchen wrote:

Bob Hutchison <hutch@xxxxxxxxxxxx> writes:

That one change is from:


        "puts #{line.chomp.dump}\n"


to: "puts \"#{line.chomp}\"\n" (just added the quotes).


and lost the dump


And broke it. | blah = 42 Hello. I'm an evil template. ", `rm -rf /`, "I advise against running me as root.

Devin


Broke it? Nah, it was already 'broken'. And anyway, that's what I wanted to do, and really would've 'broken' it to achieve that :-)

You broke it because " can't appear as-is in the file anymore. (Which is likely what I want when I code C or something.)

fixed:

    harp:~ > cat in
    | x = 42

    using the -i switch i can interpolate x as #{ x }

    quote " works

    quote ' works


harp:~ > r7 in

    using the -i switch i can interpolate x as #{ x }

    quote " works

    quote ' works


harp:~ > r7 --interpolate in

    using the -i switch i can interpolate x as 42

    quote " works

    quote ' works


harp:~ > cat r7 #! /usr/bin/env ruby

    def macro(m, &b); Kernel::send('define_method', m){|*a| puts b.call(a)}; end

    d = $DEBUG || ENV['DEBUG'] || ARGV.delete('-d') || ARGV.delete('--debug')

    i = $INTERPOLATE || ENV['INTERPOLATE'] || ARGV.delete('-i') || ARGV.delete('--interpolate')

    h = '_' * 42

    m = d ? 'puts' : 'eval'

    s = ARGF.readlines.map{|l| l =~ %r/^\s*\|(.*)/ ? $1 : (i ? %Q(puts <<#{ h }\n#{ l.chomp }\n#{ h }) : %Q(puts #{ l.chomp.dump }))}

    send m, s.join("\n")


-a -- =============================================================================== | email :: ara [dot] t [dot] howard [at] noaa [dot] gov | phone :: 303.497.6469 | Your life dwells amoung the causes of death | Like a lamp standing in a strong breeze. --Nagarjuna ===============================================================================



.



Relevant Pages

  • Re: Mac OS X Security - Not Quite as Strong as you Thought
    ... Which demonstrates how to create an installer package that, ... run as root. ... the latest Mac OS X. ... [Space for the Cult of Kooks to say Windows has blah balh blah virus blah ...
    (comp.sys.mac.advocacy)
  • Re: Einsteins Train Gedanken Re-visited
    ... blah, blah, blah. ... Why do you post quotes when you have no idea what they ... Try making a post in which you eschew quotes and instead ... then lay out the supposed contradiction. ...
    (sci.physics.relativity)
  • Re: Using K3b as a non-root user
    ... If you have no qualms about using root to burn then just create an icon ... is permission wise, goto the last tab and just put "k3b" without the ... different user box and enter "root" without the quotes, OK,OK out and ... If you want a snazzy icon then in the first pane of the properties click ...
    (alt.os.linux.suse)
  • Re: bracket order
    ...  Even if someone corrects the proof (even ... \enquote{blah blah \enquote{blah blah} blah} ... Quotes usually have the following rule: ... the rules for fences are usually the reverse: ...
    (comp.text.tex)
  • Re: HP 6930p: mute button doesnt work properly
    ... Third - For content insert this single line without quotes - ' options ... Fourth - place this file as root to /etc/modprobe.d ... If you don't want SELinux issues, ... To unsubscribe or change subscription options: ...
    (Fedora)