Skip to content

Instantly share code, notes, and snippets.

@YumaInaura
Last active August 12, 2018 07:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YumaInaura/443a5c1a06f17be67122c7f2c1f17299 to your computer and use it in GitHub Desktop.
Save YumaInaura/443a5c1a06f17be67122c7f2c1f17299 to your computer and use it in GitHub Desktop.
Let's create ruby script command — Who decide command must be binary?

Let's create ruby script command — Who decide command must be binary?

  • Put a script file in your $PATH directories.
  • Write shebang in that script.
  • Give execute permission to script.

Create ruby script in your command PATH

$ touch /usr/local/bin/ruby-echo
$ chmod +x /usr/local/bin/ruby-echo

Simple script

Just echo command arguments.

#!/usr/bin/env ruby

ARGV.each do |argv|
  puts argv
end
$ chmod +x ruby-echo

Hit that command

$ ruby-echo Are you happy hacking

Are
you
happy
hacking

My Versions

  • ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
  • Mac OS X High Sierra
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment