Your SlideShare is downloading. ×
Rc - The Plan 9 Shell
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Rc - The Plan 9 Shell

1,586
views

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.

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,586
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
9
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. RcThe Plan 9 OS Shell
  • 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. Basicsdatecat /lib/news/buildwho >user.namesrm -r junk || echo rm failed!
  • 4. Quotingrm some file# with spacesecho Hows your father?# doubled apostrophes for lit.
  • 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. Variables# values are lists of stringspath=(. /bin)# list of single stringuser=tdfont=/font/bit/pelm/ascii.9.font
  • 7. Variables continuedecho $path # => echo . /binecho $path(2) # => echo /binecho $path(2 1 2) # echo /bin ./bin# note difference:empty=()null=
  • 8. Arguments$* # argument list$1 # same as $*(1)
  • 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. 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. 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. Examples (1)for(i){ if(test -f /tmp/$i) echo $i already in /tmp if not cp $i /tmp}
  • 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. Examples (2)fn pwd{ if(~ $#dir 0) dir=‘{/bin/pwd} echo $dir}
  • 15. Theres more● functions● nice file descriptor redirection● global and local variables
  • 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.