# Standard dry-run flag

**URL:** <https://www.ruby-forum.com/t/standard-dry-run-flag/81883>\
**Category:** Ruby\
**Created:** [January 15, 2007, 11:52pm UTC](https://www.ruby-forum.com/t/standard-dry-run-flag/81883 "2007-01-15T23:52:30Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/dfb087/32.png) [@Trans](https://www.ruby-forum.com/u/Trans)\
**Post date:** [January 15, 2007, 11:52pm UTC](https://www.ruby-forum.com/t/standard-dry-run-flag/81883/1 "2007-01-15T23:52:30Z")

</div>

is there a standard global var for dry-run? e.g. $DRYRUN. i’ve been  
using $NOHARM myself, but decided i want to use whatever rake uses (I  
assume it sets a global flag so task defs can use it if need be.) which  
got me thinking it would probably be good if ruby had a standard for  
this.

t.

---

<div class="post-metadata">

**Author:** ![Trans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/dfb087/32.png) [@Trans](https://www.ruby-forum.com/u/Trans)\
**Post date:** [January 16, 2007, 4:13am UTC](https://www.ruby-forum.com/t/standard-dry-run-flag/81883/2 "2007-01-16T04:13:33Z")

</div>

Trans wrote:

> is there a standard global var for dry-run? e.g. $DRYRUN. i’ve been  
> using $NOHARM myself, but decided i want to use whatever rake uses (I  
> assume it sets a global flag so task defs can use it if need be.) which  
> got me thinking it would probably be good if ruby had a standard for  
> this.

Actually no, Rake does not store the dry-run flag in a global. It is  
stored in an options object that is local to the Rake::Application  
object. This allows multiple Rake::Applications running in the same  
memory space, each with its own set of tasks and options.

Early versions of Rake used globals, but I’ve tried to avoid them as  
much as possible in later versions.

– Jim W.

---

<div class="post-metadata">

**Author:** ![Trans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/dfb087/32.png) [@Trans](https://www.ruby-forum.com/u/Trans)\
**Post date:** [January 16, 2007, 4:57am UTC](https://www.ruby-forum.com/t/standard-dry-run-flag/81883/3 "2007-01-16T04:57:05Z")

</div>

Jim W. wrote:

> memory space, each with its own set of tasks and options.  
> curiuos, does that scenario actually arise?

but more important to me at the moment, how does one access the  
–dry-run flag in one’s task?

thanks,  
t.

---

<div class="post-metadata">

**Author:** ![Trans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/dfb087/32.png) [@Trans](https://www.ruby-forum.com/u/Trans)\
**Post date:** [January 16, 2007, 5:13am UTC](https://www.ruby-forum.com/t/standard-dry-run-flag/81883/4 "2007-01-16T05:13:07Z")

</div>

Trans wrote:

> > Actually no, Rake does not store the dry-run flag in a global. It is  
> > stored in an options object that is local to the Rake::Application  
> > object. This allows multiple Rake::Applications running in the same  
> > memory space, each with its own set of tasks and options.
> 
> curiuos, does that scenario actually arise?
> 
> but more important to me at the moment, how does one access the  
> –dry-run flag in one’s task?

oh, i forgot to ask… $DRYRUN seems to be on the order of $DEBUG which  
is built-into Ruby. that in itslef seesm a bit worrisome given your  
point. can’t setting $DEBUG in one memory space mess up another too?

t.

---

<div class="post-metadata">

**Author:** ![Trans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/dfb087/32.png) [@Trans](https://www.ruby-forum.com/u/Trans)\
**Post date:** [January 16, 2007, 11:08am UTC](https://www.ruby-forum.com/t/standard-dry-run-flag/81883/5 "2007-01-16T11:08:41Z")

</div>

Trans schrieb:

> Jim W. wrote:
> 
> > (…)
> 
> but more important to me at the moment, how does one access the  
> –dry-run flag in one’s task?

Tom, I’ve nether used Rake yet, but

task.application.options.dryrun

should give you the desired information.

Regards,  
Pit

PS: Welcome back, Jim! At least I have missed our posts.

---

<div class="post-metadata">

**Author:** ![Trans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/dfb087/32.png) [@Trans](https://www.ruby-forum.com/u/Trans)\
**Post date:** [January 16, 2007, 11:39am UTC](https://www.ruby-forum.com/t/standard-dry-run-flag/81883/6 "2007-01-16T11:39:51Z")

</div>

Sorry for the typos. Here’s what I wanted to write…

Trans schrieb:

> Jim W. wrote:
> 
> > (…)
> 
> but more important to me at the moment, how does one access the  
> –dry-run flag in one’s task?

Tom, I’ve never used Rake yet, but

task.application.options.dryrun

should give you the desired information.

Regards,  
Pit

PS: Welcome back, Jim! At least I have missed your posts.

---

<div class="post-metadata">

**Author:** ![Trans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/dfb087/32.png) [@Trans](https://www.ruby-forum.com/u/Trans)\
**Post date:** [January 16, 2007, 6:44pm UTC](https://www.ruby-forum.com/t/standard-dry-run-flag/81883/7 "2007-01-16T18:44:57Z")

</div>

Pit C. wrote:

> task.application.options.dryrun
> 
> should give you the desired information.

thanks Pit. i’ll try that.

t.
