ion issueshttps://gitlab.redox-os.org/redox-os/ion/-/issues2023-04-26T19:04:04Zhttps://gitlab.redox-os.org/redox-os/ion/-/issues/1005Implement set -o pipefail2023-04-26T19:04:04ZAndrey BienkowskiImplement set -o pipefailfeat: I want `set -o pipefail`. #272 asked for both `errexit` and `pipefail`, but so far only `errexit` is implemented.
BREAKING CHANGE: it is possible to add `pipefail` without breaking existing scripts by defaulting it to off. In the ...feat: I want `set -o pipefail`. #272 asked for both `errexit` and `pipefail`, but so far only `errexit` is implemented.
BREAKING CHANGE: it is possible to add `pipefail` without breaking existing scripts by defaulting it to off. In the perfect world both `errexit` and `pipefail` would have been always on without any way to disable them (just like in all programming languages that have exceptions except for Visual Basic), but that might break existing scripts.
perf: impact
performance none
usability increase
maintainability increase
code: input
```
set -eo pipefail
echo 1
false | true
echo 2
```
expect: output
```
1
```
reason: I want my script to fail fast by default if an external command fails.
context:
Executing an external command can fail for a million different reasons. Here are some examples:
1. The external command is not installed
2. It encounters an internal bug and [fails fast and loud](https://en.wikipedia.org/wiki/Fail-fast)
3. It receives bad input due to a bug in my script
4. An admin kills it
5. The OOM Killer kills it https://linuxwheel.com/oom-killer-explained/
6. It tries to talk to another process possibly on a different machine and that fails for any reason
7. It uses a temporary file for internal buffering and /tmp is full
8. It tries to read or write a file and that fails for any reason
A robust script can not afford to ignore the possibility that any of the external commands it executes may fail. Often the right choice of action is to fail fast because the code that follows requires that the preceding commands executed successfully.
Unix-y pipelines have an issue:
```sh
foo | bar
```
If `foo` exits successfully `bar` sees EOF. If `foo` fails `bar` also sees EOF. `bar` has no way to know whether `foo` failed or not. In many cases `bar` will exit successfully even if `foo` fails. The script has to detect that and fail. This is why you often see `set -o errexit -o pipefail` in bash.
Unfortunately `set -o errexit` is [very broken](https://mywiki.wooledge.org/BashFAQ/105) in bash which is why I'm looking for a different shell.
<!--behavior of bash/dash/zsh/fish/oil-->https://gitlab.redox-os.org/redox-os/ion/-/issues/1003Add quiet flag to math command2021-06-17T13:47:39ZDavid PurdumAdd quiet flag to math commandfeat: For some automation tasks it would be nice to enter the interactive math mode without any welcome text. For this we could use a -q/--quiet flag to silence this (similar to R).
current
```
me:~# math
Ion's integrated calculator
Ty...feat: For some automation tasks it would be nice to enter the interactive math mode without any welcome text. For this we could use a -q/--quiet flag to silence this (similar to R).
current
```
me:~# math
Ion's integrated calculator
Type in expressions to have them evaluated.
Type "help" for help.
ion-math:
```
change
```
me:~# math -q
ion-math:
```https://gitlab.redox-os.org/redox-os/ion/-/issues/986setup CI and regression tests for macOS2021-06-01T10:24:06ZRoland Teppsetup CI and regression tests for macOSmacOS: install: illegal option -- D
I was trying to install ion shell on macOS and this is the error I am getting when executing `sudo make install`
```bash
❯ sudo make install prefix=/usr
install -Dm0755 target/release/ion //usr/bin/i...macOS: install: illegal option -- D
I was trying to install ion shell on macOS and this is the error I am getting when executing `sudo make install`
```bash
❯ sudo make install prefix=/usr
install -Dm0755 target/release/ion //usr/bin/ion
install: illegal option -- D
usage: install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode]
[-o owner] file1 file2
install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode]
[-o owner] file1 ... fileN directory
install -d [-v] [-g group] [-m mode] [-o owner] directory ...
make: *** [install] Error 64
```
Google search suggests that -D option does not exist under macOS/Darwin and suggests using -d instead, but I am not experienced enough with install utility (or Makefile) to understand the subtle differences of the two and fix it myself.Ion Shell v1.0.0betahttps://gitlab.redox-os.org/redox-os/ion/-/issues/803Methods for hmap and bmap handling2021-06-01T12:30:15ZRoland KovácsMethods for hmap and bmap handlingAdd support for getting keys or key-value pairs from maps, as currently only values can be extracted.
```
@keys(map)
@entries(map)
```Add support for getting keys or key-value pairs from maps, as currently only values can be extracted.
```
@keys(map)
@entries(map)
```Ion Shell v1.0.0https://gitlab.redox-os.org/redox-os/ion/-/issues/779Tracking Issue: Supported Types For Type-Checking2021-06-01T12:00:24ZMichael Aaron Murphymmstick@pm.meTracking Issue: Supported Types For Type-CheckingWe should evaluate and expand upon our current set of supported types. Here's a basic set of what we could support:
- **[T]**: an array of like-values
- **str**: a string -- the default type
- **bool**: either `1` or `0`
- **float**: a ...We should evaluate and expand upon our current set of supported types. Here's a basic set of what we could support:
- **[T]**: an array of like-values
- **str**: a string -- the default type
- **bool**: either `1` or `0`
- **float**: a generic decimal of any size
- **int**: a generic integer of any size, which may be negative
- **i32**: 32-bit int
- **i64**: 64-bit int
- **i128**: 128-bit int
- **uint**: a generic integer of any size, which may not be negative
- **u32**: 32-bit uint
- **u64**: 64-bit uint
- **u128**: 128-bit uintIon Shell v1.0.0https://gitlab.redox-os.org/redox-os/ion/-/issues/772Create Benchmark Tests2021-06-01T13:01:05ZAlex MortonCreate Benchmark TestsIon could benefit from benchmark tests to help profile PRs that may impact performance: https://doc.rust-lang.org/1.7.0/book/benchmark-tests.html.
We can benchmark at a couple different levels here. One suggestion is to benchmark all sc...Ion could benefit from benchmark tests to help profile PRs that may impact performance: https://doc.rust-lang.org/1.7.0/book/benchmark-tests.html.
We can benchmark at a couple different levels here. One suggestion is to benchmark all scripts in the examples directory. We can also have benchmarks for lower-level units to test individual algorithms.Ion Shell v1.0.0betahttps://gitlab.redox-os.org/redox-os/ion/-/issues/705Add `type`-builtin instead of `which`2021-06-01T13:57:01ZMichael Aaron Murphymmstick@pm.meAdd `type`-builtin instead of `which`*Created by: LeonardKoenig*
**Description**: `which` is a remnant of csh and behaves on many shells differently, `type` has since replaced it as a portable and standardized alternative, cf. https://unix.stackexchange.com/questions/85249...*Created by: LeonardKoenig*
**Description**: `which` is a remnant of csh and behaves on many shells differently, `type` has since replaced it as a portable and standardized alternative, cf. https://unix.stackexchange.com/questions/85249/why-not-use-which-what-to-use-then
**Proposed change**: Add `type` shell-builtin, possibly deprecate/remove `which`.Ion Shell v1.0.0https://gitlab.redox-os.org/redox-os/ion/-/issues/441Tracking Issue: List of Methods in Ion2021-06-01T11:15:56ZMichael Aaron Murphymmstick@pm.meTracking Issue: List of Methods in Ion# String Methods
String methods return strings
- [x] $len(string) -> n string
- [x] $len(array) -> n string (@mmstick)
- [x] $len_bytes(string) -> n string
- [x] $join(array) -> string
- [x] $find(string, string) -> n string
- [x] $sta...# String Methods
String methods return strings
- [x] $len(string) -> n string
- [x] $len(array) -> n string (@mmstick)
- [x] $len_bytes(string) -> n string
- [x] $join(array) -> string
- [x] $find(string, string) -> n string
- [x] $starts_with(string, string) -> 0/1 string (@mmstick)
- [x] $ends_with(string, string) -> 0/1 string (@mmstick)
- [x] $contains(string, string) -> 0/1 string (@mmstick)
- [x] $replace(string, string) -> string (@mmstick)
- [x] $replacen(string, string) -> string (@mmstick)
- [x] $to_lowercase(string) -> string (@pithonsmear)
- [x] $to_uppercase(string) -> string (@pithonsmear)
- [x] $repeat(string, n) -> string (@mmstick)
- [x] $extension(filepath) -> string (@pithonsmear)
- [x] $basename(filepath) -> string (@pithonsmear)
- [x] $parent(filepath) -> string (@pithonsmear)
- [x] $filename(filepath) -> string (@pithonsmear)
- [ ] $or(string, expr) -> string
- If the given string does not exist, use the given expression
- [x] $reverse(string) -> string (@pithonsmear)
- [ ] $fold(array, string) -> string
- Apply a reduce/fold function to an array
- The supplied string should name a command to apply to the array
- [ ] $open(string) -> string
- Open a file and buffer the entire file into memory
- [x] $regex_replace(string, string)
- Same as $replace(), but the pattern is a regex expression
# Array Methods
Array methods return arrays
- [x] @split(string, opt<string>) -> array
- [x] @bytes(string) -> array
- [x] @chars(string) -> array
- [x] @graphemes(string) -> array
- [x] @reverse(array) -> array
- [x] @lines(string) -> array
- Split a given string by newlines
- [ ] @filter(array, string) -> array
- Apply a filter command to each element in the array
- Exit status determines which values to filter
- `@filter(array, x => matches $x '([F])\w+')`
- [ ] @map(array, string) -> array
- Apply a command to each element in the array
- Output of the command is the new value for that index
- `@map(array, x => calc $x + $x)`
- [ ] @open(array, opt<string>) -> array
- If no pattern string is supplied, split the file by newlines
- [x] @split_at(string, n) -> [string, string]
- Splits a string into a two-element array; Rust's std
- [ ] @split_args(string)
- Provides an interface for the `ArgumentSplitter` functionality in the shell.Ion Shell v1.0.0https://gitlab.redox-os.org/redox-os/ion/-/issues/420testing: Increase Test Unit Coverage2021-06-01T11:06:25ZMichael Aaron Murphymmstick@pm.metesting: Increase Test Unit CoverageWe should perform an extensive code review at some point as we near a stable release, and create tests everywhere where possible (likely refactoring with closures to increase the test-ability of certain functions). When we are ready to d...We should perform an extensive code review at some point as we near a stable release, and create tests everywhere where possible (likely refactoring with closures to increase the test-ability of certain functions). When we are ready to do this, we should make a list of all the source files in the codebase, and then one by one review, test, and check that file off the list.Ion Shell v1.0.0betamatu3bamatu3bahttps://gitlab.redox-os.org/redox-os/ion/-/issues/409Tracking Issue: List of Builtins to Implement2021-06-01T11:16:08ZMichael Aaron Murphymmstick@pm.meTracking Issue: List of Builtins to ImplementIf you have an idea for a builtin which is not on this list, discuss it below.
# Conditional Builtins
- [x] `true`: Simply returns a `SUCCESS` status
- [x] `false`: Simply returns a `FAILED` status
- [x] `not <command>`: Reverses the ex...If you have an idea for a builtin which is not on this list, discuss it below.
# Conditional Builtins
- [x] `true`: Simply returns a `SUCCESS` status
- [x] `false`: Simply returns a `FAILED` status
- [x] `not <command>`: Reverses the exit status value of the given command. (@drosseau)
- [x] `contains $key @values`: Returns 0 exit status if the key is contained within the values.
- [x] `starts-with $key @values`
- [x] `ends-with $key @values`
- [x] `matches $key $regex`: A regex-based evaluator
- [ ] `isatty [FD]`: Returns 0 exit status if the supplied FD is a tty
- [x] `and <command>`: Execute the command only if the shell's previous status is 0
- `true; and echo true`
- [x] `or <command>`: The reverse of `and`.
- `false; or echo false`
- [x] `exists -b BINARY`: Returns 0 exit status if the binary is in PATH
- [x] `exists -f PATH`: Returns 0 exit status if the path is a file
- [x] `exists -d PATH`: Returns 0 exit status if the path is a directory
- [x] `exists -s STRING`: Returns 0 exit status if the string var is not empty
- [x] `exists -a ARRAY`: Returns 0 exit status if the array var is not empty
- [x] `exists STRING`: Returns 0 exit status if the string is not empty
- [ ] `is $var $value`: Returns 0 exit status if both arguments are the same
- [ ] `is not $var $value`: The opposite of the above
- [ ] `bool $value`: If the value is "1" or "true", return 0 exit status
- [ ] < (Polish Notation)
- [ ] <= (Polish Notation)
- [ ] > (Polish Notation)
- [ ] >= (Polish Notation)
- [ ] = (Polish Notation)
# Job Control
- [x] `jobs`: Lists available background jobs
- [x] `bg`: Sends **SIGCONT** to a given background job
- [x] `fg`: Does the same as `bg`, but also brings it to the foreground via `tcsetpgrp`
- [x] `wait`: waits until background jobs have finished
- [x] `exit`: waits until background jobs have finished, and exits
- [x] `suspend`: suspends the shell via a `SIGTSTOP`
# Misc
- [x] `ion-docs`: Opens the locally-installed Ion documentation in a web browser
- [x] `which`: Prints the kind and/or path of the given command
# Math & Crypto
- [x] `calc`: built-in calculator that will eventually be arbitrary precision
- [ ] `random`: generate random numbers
# I/O
- [x] `echo`: Prints the evaluated expression to standard output
- [x] `read`: Stores the next line of input to standard input into a specified variable
- [ ] `printf`: Implement the same as other shells
- [ ] `printr`: Rusty variant maybe?
- [ ] `cat`: Perhaps copy `cat` from coreutils into Ion.
# Command Execution
- [x] `eval`: Evaluates and executes the evaluated expression
- [x] `time`: Prints timing statistics once it's job has finished
- [ ] `exec`: Replace the shell process with the specified command
# Possible Builtins From POSIX Shells
- [ ] `command -v`: often used to determine if a binary exists in a PATHIon Shell v1.0.0https://gitlab.redox-os.org/redox-os/ion/-/issues/247Implement `mapfile` as builtin2021-06-01T10:54:12ZMichael Aaron Murphymmstick@pm.meImplement `mapfile` as builtinUnlike associated arrays, these should be stored in vectors, and empty lines should be skipped.
See here how it works: https://origin.geeksforgeeks.org/mapfile-command-in-linux-with-examples/Unlike associated arrays, these should be stored in vectors, and empty lines should be skipped.
See here how it works: https://origin.geeksforgeeks.org/mapfile-command-in-linux-with-examples/Ion Shell v1.0.0