-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
182 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Arithmetic in Cicada | ||
|
||
Arithmetic is directly available in cicada. | ||
|
||
``` | ||
$ 1 + 1 | ||
2 | ||
$ 3 * 7 | ||
21 | ||
$ 7 / 3 | ||
2 | ||
$ 2 ^ 16 - 1 | ||
65535 | ||
``` | ||
|
||
## Using Parentheses | ||
|
||
``` | ||
$ (1 + 1) * 7 | ||
14 | ||
``` | ||
|
||
## Float Calculation | ||
|
||
Whenever there is a `.` in command, the whole calculation will be in float. | ||
|
||
``` | ||
$ 7.0 / 3 | ||
2.3333333333333335 | ||
$ 7.0 / 3 + 10000 | ||
10002.333333333334 | ||
``` | ||
|
||
## Single Numbers | ||
|
||
A single number will not be treated as arithmetic. It will be treated as | ||
a regular command. | ||
|
||
``` | ||
$ 42 | ||
cicada: 42: command not found | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# Cicada Shell Expansions | ||
|
||
## Brace Expansion | ||
|
||
```sh | ||
$ echo sp{el,il,al}l | ||
spell spill spall | ||
|
||
$ cp foo.txt{,.bak} | ||
# equal to `cp foo.txt foo.txt.bak` | ||
|
||
$ echo {1..5} | ||
1 2 3 4 5 | ||
|
||
$ echo {1..5..2} | ||
1 3 5 | ||
``` | ||
|
||
## Tilde Expansion | ||
|
||
``` | ||
$ echo ~/foo | ||
# equal to echo $HOME/foo | ||
``` | ||
|
||
## Parameter Expansion | ||
|
||
Currently only works in scripting. | ||
|
||
```sh | ||
$ cat foo.sh | ||
echo "the args are: $@" | ||
echo $3 $1 $2 | ||
echo $0 | ||
|
||
$ cicada foo.sh a b c | ||
the args are: a b c | ||
c a b | ||
foo.sh | ||
``` | ||
|
||
## Command Substitution | ||
|
||
Command substitution allows the output of a command to replace the command | ||
itself. Command substitution occurs when a command is enclosed as follows: | ||
|
||
``` | ||
$(command) | ||
``` | ||
|
||
or | ||
``` | ||
`command` | ||
``` | ||
|
||
## Filename Expansion | ||
|
||
``` | ||
$ echo src/*.rs | ||
src/build.rs src/execute.rs src/history.rs src/jobc.rs ... | ||
``` | ||
|
||
## Special Expansions | ||
|
||
```sh | ||
# current session process ID | ||
$ echo $$ | ||
26653 | ||
|
||
# last command exit status | ||
$ echo $? | ||
0 | ||
|
||
$ cat /etc/some-config | ||
|
||
# last command substitution | ||
$ sudo !! | ||
sudo cat /etc/some-config | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters