-
Notifications
You must be signed in to change notification settings - Fork 13
Man: slang
Slang is the default scripting language for fudge and shares some similarities to sh. It has a very simple syntax and is intentionally made to be simple and not as full fledged as other languages. It uses only three characters to denote expressions.
-
< - Redirect input pipe.
-
> - Redirect output pipe.
-
| - Pipe output from one program to another.
-
; - Concatenate commands.
To run a script you can run:
$ slang < myscript.slang
Most of the time you will just enter it in the prompt anyway. Here are some examples:
$ echo < "Hello world!"
Print the string "Hello World!". When using quotes, the data between the quotes will be written to an anonymous pipe that will later be used as input pipe.
$ echo < file.txt
Print the content of file.txt.
$ cat < file1.txt < file2.txt
Concatenate content of two files.
$ cat <1 file1.txt <0 file2.txt
Concatenate content of two files but because we have changed the order of input pipes they will be printed in reverse order.
$ echo < file1.txt > file2.txt
Print the content of file1.txt to file2.txt.
$ echo < "Hello world!" > newfile.txt
Print the string "Hello world!" to newfile.txt
$ echo < "Hello"; echo < " world!"
Print "Hello" and then print " world!".
$ echo < file.txt | nl
Print the content of file.txt and pipe it to nl. nl stands for number lines meaning all newlines will be preceded by the row number.