ion issueshttps://gitlab.redox-os.org/redox-os/ion/-/issues2021-06-01T10:51:43Zhttps://gitlab.redox-os.org/redox-os/ion/-/issues/195Add Syntax Highlighting Support for ion2021-06-01T10:51:43ZMichael Aaron Murphymmstick@pm.meAdd Syntax Highlighting Support for ionThe editor-independent solution to go for is treesitter.
While the script sizes will not require incremental parsing, treesitter is a C program and thus widely portable and supported.
The bits that are missing so far are only making fu...The editor-independent solution to go for is treesitter.
While the script sizes will not require incremental parsing, treesitter is a C program and thus widely portable and supported.
The bits that are missing so far are only making functions with arguments and references work.
`amend` will not be part of ion, because globally mutable state is very, very bad and easily to mess up things (besides making ion slower).Ion 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.0https://gitlab.redox-os.org/redox-os/ion/-/issues/397shellac: Application-Specific Tab Completions2021-06-01T11:05:12ZMichael Aaron Murphymmstick@pm.meshellac: Application-Specific Tab Completions*Created by: xTibor*
The `sudo` command should have command completions. At the moment the tab completions suggests files and directories for this command.
**Build information**:
`git rev-parse HEAD`: eb13ba645bad3b311843f38f84455ce3a5...*Created by: xTibor*
The `sudo` command should have command completions. At the moment the tab completions suggests files and directories for this command.
**Build information**:
`git rev-parse HEAD`: eb13ba645bad3b311843f38f84455ce3a53fdb8d
`rustc -V`: rustc 1.20.0-nightly (720c596ec 2017-07-08)Ion Shell v1.0.0BafDyceBafDycehttps://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/418prompt: Syntax Highlighting in Prompt2021-06-01T12:33:57ZMichael Aaron Murphymmstick@pm.meprompt: Syntax Highlighting in PromptWill require some seirous modifications to [liner](https://github.com/MovingtoMars/liner) in order to get this to work. I'm insure of the best approach for implementing this feature at the moment. Regex or a parsing crate may be ideal. S...Will require some seirous modifications to [liner](https://github.com/MovingtoMars/liner) in order to get this to work. I'm insure of the best approach for implementing this feature at the moment. Regex or a parsing crate may be ideal. Solution needs to focus on performance though. The following needs to occur:
- [ ] Color the command based on if the command exists or not
- [ ] Single quoted text should have a different color from double quoted text
- [ ] Operators should have their own unique colors
- [ ] Specific keywords should be highlighted, such as `end` and `if`
- [ ] Variables should also be highlighted
- [ ] Arrays should have a different color than variables
- [ ] Functions and aliases may also have different colors
- [ ] The coloring should be user-configurable and ideally match the grammar usage (in treesitter)Ion Shell v1.0.0Sag0Sag0Sag0Sag0https://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/506dmenu doesn't work as expected2018-07-01T17:59:19ZMichael Aaron Murphymmstick@pm.medmenu doesn't work as expected*Created by: bb010g*
**Reproduction**:
Run the following script with no arguments and press enter when prompted:
```
#!/usr/bin/env ion
echo $join(@args[1..], "|")
let foo = $(dmenu @args[1..])
let foo = $(echo hi | dmenu @arg...*Created by: bb010g*
**Reproduction**:
Run the following script with no arguments and press enter when prompted:
```
#!/usr/bin/env ion
echo $join(@args[1..], "|")
let foo = $(dmenu @args[1..])
let foo = $(echo hi | dmenu @args[1..])
echo got foo
ion -c "echo "$foo | /usr/bin/cat
ion -c "echo "$foo | dmenu @args[1..]
echo $foo | dmenu @args[1..]
```
**Expected behavior**:
I'd expect it to work equivalently to this dash script:
```
#!/usr/bin/env dash
(IFS="|"; echo "$*")
foo="`dmenu "$@"`"
foo="`echo hi | dmenu "$@"`"
echo got foo
dash -c "echo "$foo | /usr/bin/cat
dash -c "echo "$foo | dmenu "$@"
echo $foo | dmenu "$@"
```
The output will first be a blank line followed by execution stopping as dmenu waits for input. Enter a line and press `^D` to make it prompt you and keep going. `foo` will get `hi` assigned to it. `got foo` will be printed, followed by `hi` three times.
**Actual behavior**:
Ion will cause dmenu to show up with no choices. Type `bar`, press enter, and Ion presents a proper dmenu with `hi` as the choice. `got foo` and `hi` will be printed, followed by:
```
usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]
[-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]
usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]
[-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]
```
The script exits with 1.
**Build information**: [output of `rustc -V`, `git rev-parse HEAD`, `qemu-i386 -version`, `uname -a`, etc.]
```
rustc 1.19.0 (0ade33941 2017-07-17)
HEAD: 3319ffb00e3ff54db1446302a7debd7e7f7ff893
Linux bb010g-lat 4.12.8-1-ARCH #1 SMP PREEMPT Thu Aug 17 08:37:20 CEST 2017 x86_64 GNU/Linux
dmenu -v: dmenu-4.7
```
**Blocking/related**: Maybe #424? I'm not sure here.Ion Shell v1.0.0https://gitlab.redox-os.org/redox-os/ion/-/issues/508Ideas on Plugins and Security2021-06-01T11:37:18ZMichael Aaron Murphymmstick@pm.meIdeas on Plugins and SecurityWe should probably have a `ION_PLUGINS_ENABLED` variable that is set to 1 by default, but can be set to 0 to disable support for plugins. In addition, maybe we could also implement an optional `ION_PLUGINS_METHOD_WHITELIST` and `ION_PLUG...We should probably have a `ION_PLUGINS_ENABLED` variable that is set to 1 by default, but can be set to 0 to disable support for plugins. In addition, maybe we could also implement an optional `ION_PLUGINS_METHOD_WHITELIST` and `ION_PLUGINS_NAMESPACE_WHITELIST` array which can be used to designate plugins that are explicitly allowed to execute. Then maybe we could have a means of protecting certain variables from being set within scripts, or even only allowing certain variables to be set from an environment file. Suggestions welcome for ways to make Ion more secure.Ion Shell v1.0.0https://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/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/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/805Easy substring removal2023-03-10T13:53:44ZColeman McFarlandEasy substring removalI want to use ion to parse a config that looks like this, where the unique name given before the underscore `_`
is treated as part of a set.
```sh
HOST1_USERFILE=cloud-config/one.yml
HOST1_OS=ubuntu_18_04
HOST1_FACILITY=sjc1
HOST2_USE...I want to use ion to parse a config that looks like this, where the unique name given before the underscore `_`
is treated as part of a set.
```sh
HOST1_USERFILE=cloud-config/one.yml
HOST1_OS=ubuntu_18_04
HOST1_FACILITY=sjc1
HOST2_USERFILE=cloud-config/two.yml
HOST2_OS=ubuntu_18_04
HOST2_FACILITY=sjc1
```
I am using hashmap as a set. The following doesn't _quite_ work, because the "" empty string is not treated as an argument to `@replace`.
```
let hosts:hmap[] = [ ]
let name = $replace("HOST1_USERFILE", "_USERFILE" "")
let hosts[$name] = $name
```
I could do use a space instead of empty string:
```
let name = $replace("HOST1_USERFILE", "_USERFILE" " ") # a space, inst
```
... but the space is preserved in the value of `$name`.
I could use trim #802 when it lands, but a dedicated substring removal method might be nice.Ion Shell v1.0.0https://gitlab.redox-os.org/redox-os/ion/-/issues/828Process hang with subshell2019-02-09T00:07:39ZMichael Aaron Murphymmstick@pm.meProcess hang with subshellStumbled across an issue that can cause ion to hang:
```
for src in src crates/*; echo $(echo -e "### $src\n ```\n$(tokei $src)\n```"); end
```
It doesn't always happen, but this will usually happen after the second attempt.Stumbled across an issue that can cause ion to hang:
```
for src in src crates/*; echo $(echo -e "### $src\n ```\n$(tokei $src)\n```"); end
```
It doesn't always happen, but this will usually happen after the second attempt.Ion Shell v1.0.0https://gitlab.redox-os.org/redox-os/ion/-/issues/857Tracking Issue: Fast math roadmap2021-06-01T11:49:38ZAdminXVIITracking Issue: Fast math roadmapMath is currently too slow. Proposed roadmap:
- [x] Default to integer, rather than float
- [ ] Store the types, rather than parsing back and forth
- [x] Use lexical for parsing, rather than the stdlibMath is currently too slow. Proposed roadmap:
- [x] Default to integer, rather than float
- [ ] Store the types, rather than parsing back and forth
- [x] Use lexical for parsing, rather than the stdlibIon Shell v1.0.0https://gitlab.redox-os.org/redox-os/ion/-/issues/877Is ion language embeddable into Rust?2020-12-12T23:02:21ZDieter KonradIs ion language embeddable into Rust?Like lua in c?Like lua in c?Ion Shell v1.0.0https://gitlab.redox-os.org/redox-os/ion/-/issues/880Multiple LHS values with indexing using math assignment operates on entire array2020-12-12T23:10:27ZRoland KovácsMultiple LHS values with indexing using math assignment operates on entire array* ion revision: 04f7be9
* expected behavior: indexed assignment only applies to the index position.
```
$ let a:[int] = [0 0 0]
$ let b:int = 0
$ let a[1] b += 1 1
$ echo @a
1 1 1 # [0 1 0] expected
$ echo $b
1
```* ion revision: 04f7be9
* expected behavior: indexed assignment only applies to the index position.
```
$ let a:[int] = [0 0 0]
$ let b:int = 0
$ let a[1] b += 1 1
$ echo @a
1 1 1 # [0 1 0] expected
$ echo $b
1
```Ion Shell v1.0.0https://gitlab.redox-os.org/redox-os/ion/-/issues/886Replace method does not consider strings of zero length to be an input2021-03-18T17:21:54ZMichael Aaron Murphymmstick@pm.meReplace method does not consider strings of zero length to be an inputThis currently gives an error about needing an extra argument
```
echo $replace("foobar" "bar" "")
```This currently gives an error about needing an extra argument
```
echo $replace("foobar" "bar" "")
```Ion Shell v1.0.0https://gitlab.redox-os.org/redox-os/ion/-/issues/900"help" builtin command prints garbage2020-12-12T22:59:12Zngirard"help" builtin command prints garbagetyping `help` gives
```
fnhelpjobsreaddirsends-withexistspushdtestdisowndroptypesetexitisunaliasisattybghistorycalckeybindingsrandomsuspendstarts-withaliastrueboolcontainseqstatuspopdsourcewhichfalsefgmatchescdevalechowaitexec
```typing `help` gives
```
fnhelpjobsreaddirsends-withexistspushdtestdisowndroptypesetexitisunaliasisattybghistorycalckeybindingsrandomsuspendstarts-withaliastrueboolcontainseqstatuspopdsourcewhichfalsefgmatchescdevalechowaitexec
```Ion Shell v1.0.0https://gitlab.redox-os.org/redox-os/ion/-/issues/910Nicer error messages2021-07-18T05:53:40ZDiego GanglNicer error messagesRight now, Ion throws error messages like this:
```ion: pipeline execution error: command exec error: Permission denied (os error 13)```
While they are correct and tell you what the problem is, they could be more polished like rustc's e...Right now, Ion throws error messages like this:
```ion: pipeline execution error: command exec error: Permission denied (os error 13)```
While they are correct and tell you what the problem is, they could be more polished like rustc's errors (I'm only talking about the interactive prompt in this case).
### No permissions
```
You don't have permission to open [FILE]. The owner is [USER].
Permissions are: rw--x---
```
### Executables that can't be run
If it doesn't have any exec permissions:
```
Can't run [FILE]. It's not an executable.
Try running chmod +x [FILE].
```
If it has one, but we can't run it:
```
[FILE] is an executable but you don't have permission to run it.
The owner is [USER]. Permissions are: rwx-w---
Try running chmod +x [FILE].
```
### Command not found
```Command not found: pyothn. Did you mean "python"?```
If the command ends with a forward slash, it's a path not a command. The error should be more like:
```Directory not found```Ion Shell v1.0.0https://gitlab.redox-os.org/redox-os/ion/-/issues/913No expected practices documentation for startup2020-12-12T22:51:57ZSteven PeaseNo expected practices documentation for startupGetting ion set up as my default shell.
I couldn't find a "best practices" / "expected practices" documentation for startup scripts. Eg equivalents of .profile, .bashrc, .bash_profile, etc. For now I've just been putting everything in t...Getting ion set up as my default shell.
I couldn't find a "best practices" / "expected practices" documentation for startup scripts. Eg equivalents of .profile, .bashrc, .bash_profile, etc. For now I've just been putting everything in the initrc file.
Thanks!Ion Shell v1.0.0