# Rake "sh" does not echo command

**URL:** <https://www.ruby-forum.com/t/rake-sh-does-not-echo-command/151535>\
**Category:** Ruby\
**Created:** [October 22, 2008, 4:39pm UTC](https://www.ruby-forum.com/t/rake-sh-does-not-echo-command/151535 "2008-10-22T16:39:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rake\_newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/2bfe46/32.png) [@rake\_newb](https://www.ruby-forum.com/u/rake_newb)\
**Post date:** [October 22, 2008, 4:39pm UTC](https://www.ruby-forum.com/t/rake-sh-does-not-echo-command/151535/1 "2008-10-22T16:39:29Z")

</div>

From what I have read, I would expect the ruby/rake “sh” command to echo  
the system call to STDOUT - instead just executing it. Is there some  
reason why ruby/rake would not be echoing my system commands to my  
command window? I am running in Windows. Here is an example:

rule “.#{OBJ\_EXT}” =\> lambda{|objfile| find\_source(objfile)} do |t|  
puts “Building object file for #{t.source}”  
sh “#{COMPILER} #{C\_OPTS} #{C\_OBJ\_DIR} #{C\_INC\_PATHS} #{C\_FLAGS}  
#{C\_TARGET} #{t.source}”  
end

The execution of the above rule never echoes the command following “sh”.  
Why is that? Is there another shell command I should be using? I realize  
that I could just precede everything with a puts of the same line, but  
it seems like I am missing something.

Thanks.

---

<div class="post-metadata">

**Author:** ![rake\_newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/2bfe46/32.png) [@rake\_newb](https://www.ruby-forum.com/u/rake_newb)\
**Post date:** [October 22, 2008, 5:16pm UTC](https://www.ruby-forum.com/t/rake-sh-does-not-echo-command/151535/2 "2008-10-22T17:16:01Z")

</div>

I always add:

# I like to see the shell commands as they are executed

verbose(true)

to my rakefiles. You can also do things like:

vebose(true) do  
sh this\_verbose\_command  
end

or

verbose(false) do  
sh that\_quiet\_command  
end

The default is not to echo the commands. My Makefile heritage finds  
this  
odd, but now that I’ve figured out how to get around it, it’s not so odd  
anymore.

There might even be a .rakerc file somewhere I could add that to.  
Hmmm…  
if not, then perhaps I have finally come up with an idea that I could  
implement and contribute back.

–wpd

---

<div class="post-metadata">

**Author:** ![rake\_newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/2bfe46/32.png) [@rake\_newb](https://www.ruby-forum.com/u/rake_newb)\
**Post date:** [October 22, 2008, 5:24pm UTC](https://www.ruby-forum.com/t/rake-sh-does-not-echo-command/151535/3 "2008-10-22T17:24:42Z")

</div>

Thanks Patrick.

Patrick D. wrote:

> I always add:
> 
> # I like to see the shell commands as they are executed
> 
> verbose(true)
