Skip to content

Instantly share code, notes, and snippets.

@jeffmccune
Created April 27, 2012 23:18
Show Gist options
  • Save jeffmccune/2514237 to your computer and use it in GitHub Desktop.
Save jeffmccune/2514237 to your computer and use it in GitHub Desktop.
Ruby, I'm surprised by you, OK? You're not bash.
[jeff@maynard] (feature/master/registry_key_purge_values)(dirty)[█▆▁]1.8.7 /vagrant/modules/registry
$ cat foo.rb
#! /bin/bash
#
echo bar
[jeff@maynard] (feature/master/registry_key_purge_values)(dirty)[█▆▁]1.8.7 /vagrant/modules/registry
$ ruby foo.rb
bar
@slippycheeze
Copy link

⚡ head ./spec/unit/agent_spec.rb 
#!/usr/bin/env rspec
require 'spec_helper'
require 'puppet/agent'

class AgentTestClient
  def run
    # no-op
  end
  def stop
    # no-op

⚡ ./spec/unit/agent_spec.rb
/Users/daniel/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': iconv will be deprecated in the future, use String#encode instead.
  34/34:       100% |==========================================| Time: 00:00:00

Finished in 0.13905 seconds
34 examples, 0 failures

@jeffmccune
Copy link
Author

@daniel-pittman

Right, but marking the file as executable and letting the system start the interpreter process is different than using the shell and passing the script directly to ruby:

Notice I do ruby foo.rb and not ./foo.rb

The syntax checking command for a ruby file is something like: ruby -W1 -c foo.rb

@slippycheeze
Copy link

Ah. Yes, so I see. How precious.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment