Difference between revisions of "Oh"

From ArchWiki
Jump to: navigation, search
(Add i18n template)
Line 1: Line 1:
 
[[Category:Command shells (English)]]
 
[[Category:Command shells (English)]]
 
{{i18n|Oh}}
 
{{i18n|Oh}}
The oh shell ([https://aur.archlinux.org/packages.php?ID=50007 AUR]), formerly known as "gosh", is inspired by the Plan9 shell [http://cm.bell-labs.com/sys/doc/rc.html rc] and written in Google's new [http://golang.org/ Go] programming language, which also is inspired by Plan9 in some ways.
+
The oh shell ([https://aur.archlinux.org/packages.php?ID=58587 AUR]), formerly known as "gosh", is inspired by the Plan9 shell [http://cm.bell-labs.com/sys/doc/rc.html rc] and written in Google's new [http://golang.org/ Go] programming language, which also is inspired by Plan9 in some ways.
  
 
From the official [https://github.com/michaelmacinnis/oh/blob/master/README README]:
 
From the official [https://github.com/michaelmacinnis/oh/blob/master/README README]:
Line 31: Line 31:
 
         define x: integer 0
 
         define x: integer 0
 
         define y: integer 0
 
         define y: integer 0
 
 
         public move: method a b {
 
         public move: method a b {
 
             set $self::x: add $self::x a
 
             set $self::x: add $self::x a
 
             set $self::y: add $self::y b
 
             set $self::y: add $self::y b
 
         }
 
         }
 
 
         public show: method {
 
         public show: method {
 
             echo $self::x $self::y
 
             echo $self::x $self::y

Revision as of 10:10, 18 April 2012

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.


Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어


External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

The oh shell (AUR), formerly known as "gosh", is inspired by the Plan9 shell rc and written in Google's new Go programming language, which also is inspired by Plan9 in some ways.

From the official README:


Oh is a Unix shell written in Go. Like the rc shell, oh is similar in spirit but different in detail from other Unix shells.

Oh extends the shell's programming language features without sacrificing the shell's interactive features. The following commands behave as expected:

   date
   cat /usr/share/dict/words
   who >user.names
   who >>user.names
   wc <file
   echo [a-f]*.c
   who | wc
   who; date
   cc *.c &
   mkdir junk && cd junk
   cd ..
   rm -r junk || echo "rm failed!"

Oh has objects but no classes. Objects can be created from scratch using the 'object' command. Private members are defined using the 'define' command and public members are defined using the 'public' command:

   define point: object {
       define x: integer 0
       define y: integer 0
       public move: method a b {
           set $self::x: add $self::x a
           set $self::y: add $self::y b
       }
       public show: method {
           echo $self::x $self::y
       }
   }

Objects can also be created by cloning an existing object:

   define o: point::clone

Modules are objects. The command below creates an object called 'm'. Public, top-level definitions in 'file' can be accessed using the object 'm'.

   define m: import file

Channels are objects. Oh exposes channels, which are implicit in other shells in the form of pipes, as first-class values. Channels can be created with the 'channel' command:

   define c: channel

Oh incorporates many features, including first-class functions, from the Scheme dialect of Lisp. Like Lisp, oh uses the same syntax for code and data. When data is sent across a channel it is converted to text so that it can be sent to (or even through) external Unix programs.