RcThe Plan 9 OS Shell
Goals● Improve on other UNIX shells● Better parsing● Be like Bourne/BASH but with "less  idiosyncratic syntax"[1]  ○ Synta...
Basicsdatecat /lib/news/buildwho >user.namesrm -r junk || echo rm failed!
Quotingrm some file# with spacesecho Hows your father?# doubled apostrophes for lit.
Patterns and Wildcardsls foo* # foo_bar foo_baz fools foo? # fool foot foo_ls foo[a-z] # fool footls foo[~a-z] # foo_
Variables# values are lists of stringspath=(. /bin)# list of single stringuser=tdfont=/font/bit/pelm/ascii.9.font
Variables continuedecho $path # => echo . /binecho $path(2) # => echo /binecho $path(2 1 2) # echo /bin ./bin# note differ...
Arguments$* # argument list$1 # same as $*(1)
Concatenation^ is the concat. operatorecho (a b c)^(1 2 3)  # => echo a1 b2 c3src=(main subr io)cc $src^.c  # => cc main.c...
Use command outputcat `{ls -tr | sed 10q}...output contents of ten most recent files(ascending)(btw: thats a backtick, or ...
The gloves come off..."Rc has syntax for some kinds of non-linear buttreelike pipelines."[1]cmp <{old} <{new}...cmps input...
Examples (1)for(i){   if(test -f /tmp/$i)      echo $i already in /tmp   if not      cp $i /tmp}
Examples (2)ps1=’% ’                   case *tab=’    ’                    switch($1)fn cd{                        case /*...
Examples (2)fn pwd{  if(~ $#dir 0)    dir=‘{/bin/pwd}  echo $dir}
Theres more● functions● nice file descriptor redirection● global and local variables
References1. http://plan9.bell-labs.com/sys/doc/rc.html2. https://en.wikipedia.org/wiki/Rc3. http://plan9.bell-labs.   com...
Upcoming SlideShare
Loading in...5
×

Rc - The Plan 9 Shell

1,787

Published on

I give a brief overview of the rc shell from the Plan 9 operating system. Rc is also available on Mac and Linux OSs via plan9port.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,787
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
11
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Rc - The Plan 9 Shell

  1. 1. RcThe Plan 9 OS Shell
  2. 2. Goals● Improve on other UNIX shells● Better parsing● Be like Bourne/BASH but with "less idiosyncratic syntax"[1] ○ Syntax draws on C rather than Algol 68 (brackets rather than keywords)if(test -f junk) rm junkif test -f junk; then rm junk; fi
  3. 3. Basicsdatecat /lib/news/buildwho >user.namesrm -r junk || echo rm failed!
  4. 4. Quotingrm some file# with spacesecho Hows your father?# doubled apostrophes for lit.
  5. 5. Patterns and Wildcardsls foo* # foo_bar foo_baz fools foo? # fool foot foo_ls foo[a-z] # fool footls foo[~a-z] # foo_
  6. 6. Variables# values are lists of stringspath=(. /bin)# list of single stringuser=tdfont=/font/bit/pelm/ascii.9.font
  7. 7. Variables continuedecho $path # => echo . /binecho $path(2) # => echo /binecho $path(2 1 2) # echo /bin ./bin# note difference:empty=()null=
  8. 8. Arguments$* # argument list$1 # same as $*(1)
  9. 9. Concatenation^ is the concat. operatorecho (a b c)^(1 2 3) # => echo a1 b2 c3src=(main subr io)cc $src^.c # => cc main.c subr.c io.c
  10. 10. Use command outputcat `{ls -tr | sed 10q}...output contents of ten most recent files(ascending)(btw: thats a backtick, or leftquote, we lisperswould say quasiquote)
  11. 11. The gloves come off..."Rc has syntax for some kinds of non-linear buttreelike pipelines."[1]cmp <{old} <{new}...cmps input is olds and news output inparallel
  12. 12. Examples (1)for(i){ if(test -f /tmp/$i) echo $i already in /tmp if not cp $i /tmp}
  13. 13. Examples (2)ps1=’% ’ case *tab=’ ’ switch($1)fn cd{ case /* builtin cd $1 && dir=$1 switch($#*){ prompt=(‘{basename ‘{pwd}} case 0 ^$ps1 $tab) dir=$home case */* ..* prompt=($ps1 $tab) dir=() prompt=(‘{basename ‘{pwd}} ^$ps1 $tab) case * dir=() prompt=($1^$ps1 $tab) } } }
  14. 14. Examples (2)fn pwd{ if(~ $#dir 0) dir=‘{/bin/pwd} echo $dir}
  15. 15. Theres more● functions● nice file descriptor redirection● global and local variables
  16. 16. References1. http://plan9.bell-labs.com/sys/doc/rc.html2. https://en.wikipedia.org/wiki/Rc3. http://plan9.bell-labs. com/magic/man2html/1/rc4.
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×