JRUBY(1)

πŸ’– JRUBY πŸ’–

okay so bestie, welcome to the jruby(1) page β€” it lives in the LOCAL manual, section 1, and it's literally your group chat invite to the coolest thing ever. grab a boba, sit down, we're doing this 🫢


✨ NAME ✨

jruby β€” an interpreted object-oriented scripting language. that's it, that's the whole vibe. iconic behavior fr fr πŸ‘‘


🌸 SYNOPSIS 🌸

jruby [--copyright] [--version] [-Sacdlnpswvy] [-0[octal]]
      [-C directory] [-F pattern] [-I directory] [-K c] [-T[level]]
      [-e command] [-i[extension]] [-r library] [-x[directory]] [--]
      [program_file] [argument ...]

lowkey a lot of little letters but don't panic, we're gonna go through every single one πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

Jruby is a 100% pure-Java implementation of Ruby, which is an interpreted scripting language built for quick and easy object-oriented programming. it's giving "I can do anything" energy ✨

it has so many features for processing text files and doing system management tasks (literally like Perl, if you know, you know), and it's simple, straight-forward, and extensible. the way that it just *works*… obsessed πŸ˜­πŸ’–


πŸŽ€ OPTIONS πŸŽ€

so the Ruby interpreter accepts these command-line options (switches), and ngl they're quite similar to the ones in perl(1). every single one, coming right up πŸ‘‡

  • --copyright β€” prints the copyright notice. legal girlies rise 🫢
  • --version β€” prints the version of the Ruby interpreter.
  • -0[octal] β€” (that's the digit β€œzero”, not the letter, bestie πŸ’€). this specifies the input record separator ($/) as an octal number. if no digit is given, the null character gets taken as the separator. other switches can follow the digits. -00 turns Ruby into paragraph mode. -0777 makes Ruby read the whole file at once as a single string, since there's no legal character with that value. wild, right?
  • -C directory β€” causes Ruby to switch to the directory. we're moving, pack your bags 🧳
  • -F pattern β€” specifies input field separator ($;).
  • -I directory β€” used to tell Ruby where to load the library scripts from. the directory path gets added to the load-path variable ($:).
  • -K kcode β€” specifies KANJI (Japanese) encoding. ζ—₯本θͺž girlies we see you 🌸
  • -S β€” makes Ruby use the PATH environment variable to search for the script, unless its name begins with a slash. this is used to emulate #! on machines that don't support it, in the following manner:
#! /usr/local/bin/ruby
# This line makes the next one a comment in Ruby \
  exec /usr/local/bin/ruby -S $0 $*
  • -T[level] β€” turns on taint checks at the specified level (default 1). safety first babes πŸ›‘οΈ
  • -a β€” turns on auto-split mode when used with -n or -p. in auto-split mode, Ruby executes this at the beginning of each loop:
$F = $_.split
  • -c β€” causes Ruby to check the syntax of the script and exit without executing it. if there are no syntax errors, Ruby will print β€œSyntax OK” to the standard output. the pre-game check we all need ✨
  • -d, --debug β€” turns on debug mode. $DEBUG will be set to true.
  • -e command β€” specifies script from command-line while telling Ruby not to search the rest of the arguments for a script file name.
  • -h, --help β€” prints a summary of the options. help me help you 🫢
  • -i extension β€” specifies in-place-edit mode. the extension, if specified, is added to the old file name to make a backup copy. for example:
% echo matz > /tmp/junk
% cat /tmp/junk
matz
% ruby -p -i.bak -e '$_.upcase!' /tmp/junk
% cat /tmp/junk
MATZ
% cat /tmp/junk.bak
matz
  • -l β€” (that's the lowercase letter β€œell”, okay, not a one πŸ™ˆ). enables automatic line-ending processing, which means to firstly set $\ to the value of $/, and secondly chops every line read using chop!.
  • -n β€” causes Ruby to assume the following loop around your script, which makes it iterate over file name arguments somewhat like sed -n or awk:
while gets
  ...
end
  • -p β€” acts mostly same as the -n switch, but prints the value of variable $_ at the each end of the loop. for example:
% echo matz | ruby -p -e '$_.tr! "a-z", "A-Z"'
MATZ
  • -r library β€” causes Ruby to load the library using require. it's useful when using -n or -p.
  • -s β€” enables some switch parsing for switches after the script name but before any file name arguments (or before a --). any switches found there get removed from ARGV and set the corresponding variable in the script. for example:
#! /usr/local/bin/ruby -s
# prints "true" if invoked with `-xyz' switch.
print "true\n" if $xyz

on some systems $0 does not always contain the full pathname, so you need the -S switch to tell Ruby to search for the script if necessary. this is to handle embedded spaces or such. a better construct than $* would be ${1+"$@"}, but it does not work if the script is being interpreted by csh(1). yeah. we know. 😭

  • -v, --verbose β€” enables verbose mode. Ruby will print its version at the beginning, and set the variable $VERBOSE to true. some methods print extra messages if this variable is true. if this switch is given, and no other switches are present, Ruby quits after printing its version. she said bye then actually left πŸ’€
  • -w β€” enables verbose mode without printing the version message at the beginning. it sets the $VERBOSE variable to true.
  • -x[directory] β€” tells Ruby that the script is embedded in a message. leading garbage will be discarded until the first line that starts with β€œ#!” and contains the string, β€œruby”. any meaningful switches on that line will be applied. the end of script must be specified with either EOF, ^D (control-D), ^Z (control-Z), or the reserved word __END__. if the directory name is specified, Ruby will switch to that directory before executing the script. hidden treasure hunt energy πŸ—ΊοΈβœ¨
  • -y, --yydebug β€” turns on compiler debug mode. Ruby will print a bunch of internal state messages during compiling scripts. you don't have to specify this switch, unless you're going to debug the Ruby interpreter. > like fr, only the brave ones touch this one πŸ”₯

and that's the whole page, bestie!! every flag, every example, nothing skipped, no cap πŸ’…βœ¨

cute little sign-off: this page comes from the UNIX manual, dated Apr 2, 2007, and yeah that's the vintage drop but it's still serving πŸŽ€πŸ¦‹ go write something iconic, you've got this πŸ’–πŸŒˆ

πŸ“¦ where this page comes from