Project

General

Profile

Actions

Feature #3631

closed

[PATCH] lib/rake.rb: allow passing nil to sh() and ruby()

Added by sunaku (Suraj Kurapati) over 13 years ago. Updated over 12 years ago.

Status:
Closed
Target version:
-
[ruby-core:31551]

Description

=begin
This patch allows you to pass nil values to Rake's sh() and ruby()
methods. This is useful when you want to conditionally pass arguments
to the child program you are executing.

For example, suppose you want to pass '-v' to a child program if the
user ran Rake in tracing mode (rake --trace), but not otherwise:

sh 'asciidoc', ('-v' if Rake.application.options.trace), 'input.txt'

Without this patch, you have to carefully construct an arguments array
so that it does not contain nil values:

args = []
args << '-v' if Rake.application.options.trace
args << 'input.txt'
sh 'asciidoc', *args

Sadly, this becomes very tiresome when performed more than a few times.

Thanks for your consideration.
=end


Files

Actions #1

Updated by nobu (Nobuyoshi Nakada) over 13 years ago

=begin
Hi,

At Fri, 30 Jul 2010 14:02:21 +0900,
Suraj Kurapati wrote in [ruby-core:31551]:

For example, suppose you want to pass '-v' to a child program if the
user ran Rake in tracing mode (rake --trace), but not otherwise:

sh 'asciidoc', ('-v' if Rake.application.options.trace), 'input.txt'

In 1.9, you can write as:

sh 'asciidoc', *('-v' if Rake.application.options.trace), 'input.txt'

--
Nobu Nakada

=end

Actions #2

Updated by sunaku (Suraj Kurapati) over 13 years ago

=begin
Thanks for the tip Nobu! :-)
=end

Actions #3

Updated by shyouhei (Shyouhei Urabe) over 13 years ago

  • Status changed from Open to Assigned
  • Assignee set to nobu (Nobuyoshi Nakada)

=begin

=end

Updated by sunaku (Suraj Kurapati) over 12 years ago

I submitted this patch directly to the Rake project:

https://github.com/jimweirich/rake/pull/79

If it is accepted there, then perhaps someday it will
find its way back into ruby-core. One can only dream. :)

Updated by sunaku (Suraj Kurapati) over 12 years ago

Patch was rejected upstream, so please close this issue.

Updated by drbrain (Eric Hodel) over 12 years ago

  • Status changed from Assigned to Closed
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0