Forum: Ruby Rake questions

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Eric A. (Guest)
on 2006-06-03 03:05
(Received via mailing list)
1. Is there some reason to prefer
      sh %{ls -ltr}
    over
      sh "ls -ltr"
    ?

2. My standard csh idiom for creating a log
    file is this:
        ls |& tee test.log

    But when I try that in sh, the process
    hangs, and nothing is written. truss
    shows this:
      waitid(P_PID, ...WEXITED|WTRAPPED|WNOWAIT)
      (sleeping...)

    Is there a Rakefile idiom for displaying
    execution results and also saving them
    in a file?

3. A single quote (') in a comment causes a parse
    error. Is this a known rake bug? If not,
    what's the best way to report it?

thanks
eric
David B. (Guest)
on 2006-06-03 06:52
(Received via mailing list)
Hi Eric,

I'm by no means a rake expert but since no-one else has answered;

On 6/3/06, Eric A. <removed_email_address@domain.invalid> wrote:
> 1. Is there some reason to prefer
>       sh %{ls -ltr}
>     over
>       sh "ls -ltr"
>     ?

Perhaps so that you can do this;

    sh %{grep "long long" *}

without having to escape the double quotes. Just a guess.

>     Is there a Rakefile idiom for displaying
>     execution results and also saving them
>     in a file?

I'd do this;

    def tee(output, file_name)
      puts output
      File.open(file_name, "a") {|f| f << output }
    end

    task :default do
      tee `ls`, "out.log"
    end

> 3. A single quote (') in a comment causes a parse
>     error. Is this a known rake bug? If not,
>     what's the best way to report it?

I'm not sure exactly what you mean by this. Are you saying

    # this is a comment with a quote '

causes a parse error? Anyway, I'm not sure where to report bugs to
Rake but I'd probably try the devel mailing list;

    http://rubyforge.org/mailman/listinfo/rake-devel

They should at least point you in the right direction.
Eric A. (Guest)
on 2006-06-06 01:24
(Received via mailing list)
David B. wrote:
>
>    sh %{grep "long long" *}
>
> without having to escape the double quotes. Just a guess.
>
Darn good guess, as it turns out. I was just doing something
similar using rsync in my Rakefile, and was glad I had
encoded %{...} for that very reason.

>>     Is there a Rakefile idiom for displaying
>    task :default do
>      tee `ls`, "out.log"
>    end
>
Doh! Of course. Thanks.

>
>    http://rubyforge.org/mailman/listinfo/rake-devel
>
> They should at least point you in the right direction.
>
Another great tip. Thanks. I was at the Rake site, but
missed that pointer somehow.
This topic is locked and can not be replied to.