NOTE:This blog had a good run, but is now in retirement.
If you enjoy the content here, please support Gregory's ongoing work on the Practicing Ruby journal.

USP: Prerequisite Knowledge

2011-09-13 01:29, written by Eric Wong

Introduction (by RKlemme)

This series started out with this posting of Eric to ruby-talk:

I would like to do a series of mailing list posts on the subject of Unix systems programming in Ruby. I only intend to cover standardized, POSIX-compliant features of the standard Ruby distribution. No extensions or Linux-only parts.

I volunteered to edit his postings and mirror them on the “Practicing Ruby” blog (formerly “Ruby Best Practices”). I will try to mirror articles as quickly as possible but the blog will certainly be lagging behind a bit.

You may discuss articles here on the blog or on the mailing list where there are originally published: usp.ruby@librelist.org (subscribe)

Now let’s start with the original text.

What you should know

  • You should know basic Ruby syntax.
  • Bourne shell knowledge will be useful, but not required.
  • You do not need to know C, though I’ll refer to and map Ruby methods to corresponding or analogous C functions.
  • You must know that that two (or more) variables (in Ruby) can refer to the same underlying object. This concept is present in Unix, so it is very important one understand this:
       a = "this is a string"
       b = a      # 'b' refers to the same String object as 'a'
       a << "!"   # modifies the String object 'a' points to

       "this is a string!" == a

       # You should understand why the following statements are true:
       "this is a string!" == b
       "this is a string" != b

Notations/conventions

  • Ruby method documentation references (should be the same as Ruby documentation)
    • IO.pipe — class/singleton method
    • IO#stat — instance method
  • C function documentation references
    • pipe(2) — “#{function_name}(#{section})”
      The C function manpage can be accessed as:
      man #{section} #{function_name}
      so you can open documentation for pipe(2) using the command: man 2 pipe

That’s all I can think of for now…

License: GPLv3 (or later, at the discretion of Eric Wong)

blog comments powered by Disqus