ion issueshttps://gitlab.redox-os.org/redox-os/ion/-/issues2020-12-12T21:56:29Zhttps://gitlab.redox-os.org/redox-os/ion/-/issues/991Simplify slicing2020-12-12T21:56:29Zmatu3baSimplify slicingfeat: Remove edge cases
BREAKING CHANGE: progams relying on slicing MUST be revalidated
perf: impact
performance none
usability increase
maintainability increase
code: input
```sh
let array = [{1..10}]
let array2 = [{1...10}]
echo...feat: Remove edge cases
BREAKING CHANGE: progams relying on slicing MUST be revalidated
perf: impact
performance none
usability increase
maintainability increase
code: input
```sh
let array = [{1..10}]
let array2 = [{1...10}]
echo @array
echo @array2
```
expect: output
```
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
```
actual: output
```
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9 10
```
reason: better usability and remove edge case
context: We should reuse the inclusive annotation for slicing to simplify working with the shell.
```
let array2 = [{1..=10}]
```Ion Shell v1.0.0betahttps://gitlab.redox-os.org/redox-os/ion/-/issues/962alias of a fn: allow function alias2021-06-02T14:09:37Zkoliaalias of a fn: allow function alias(coerce trailing arguments into an array) -> not sure why this is needed with the inbuilds.
feat:
`alias cmd = _cmd_fn` where RHS `_cmd_fn` is a fn
with the semantics that `cmd args...` calls `_cmd_fn args...` while coercing trailing a...(coerce trailing arguments into an array) -> not sure why this is needed with the inbuilds.
feat:
`alias cmd = _cmd_fn` where RHS `_cmd_fn` is a fn
with the semantics that `cmd args...` calls `_cmd_fn args...` while coercing trailing args into an array.
Alternatively, a new keyword other than the existing `alias` keyword could be used.
This would be non-breaking syntactic sugar. It would allow you to do for example:
```
fn _f arg1 trailing:[str]
...
end
alias f = _f
f arg1
f arg1 arg2
f arg1 arg2 arg3
...
```
which would call:
```
_f arg1 []
_f arg1 [ arg2 ]
_f arg1 [ arg2 arg3 ]
```
The use case is exposing commands for which typing the `[]` is prohibitive. For example, to use [zoxide](https://github.com/ajeetdsouza/zoxide/issues/66) with ion, the best that can be currently done as far as I can tell is `z [ dirname ]`, which is not ergonomic enough for a command that needs to be very fast to type, since its purpose is to be a faster more convenient `cd`. This would allow `z dirname`.
This comes up in other issues like #952.
This proposal is aiming at the same use case as #834, without changing `fn` or `let` definitions. Instead, the proposed alias would just be syntactic sugar that avoids requiring the brackets. (Supporting functions with variadic args would make `fn` definitions more complicated and less clear.)
bash/dash/zsh/fish all allow functions to have variable numbers of arguments.unplannedhttps://gitlab.redox-os.org/redox-os/ion/-/issues/944Dynamic Configuration2021-01-08T16:43:43ZNathaniel Barragancontact@nathanielbarragan.xyzDynamic ConfigurationI do notice that the configuration of this shell dynamically (After compilation) is lacking. Perhaps we can add some builtins for configuration, OR make environment variables change different configurations? For example, turning implicit...I do notice that the configuration of this shell dynamically (After compilation) is lacking. Perhaps we can add some builtins for configuration, OR make environment variables change different configurations? For example, turning implicit cd off could be done by setting the environment variable `ION_IMPLICIT_CD=false`?
I suppose this is more of an RFC as opposed to an actual issue?unplannedhttps://gitlab.redox-os.org/redox-os/ion/-/issues/866Arbitrary character for array expansion2020-12-12T23:04:37ZAdminXVIIArbitrary character for array expansionThe `@split($(command) "\n")` syntax is too verbose for expansion, and is quite common.
It would be better if Ion had a shorthand notation.
~~Proposition: `@"\n"(command)`, where "\n" can be any arbitrary separator.~~
This could cause c...The `@split($(command) "\n")` syntax is too verbose for expansion, and is quite common.
It would be better if Ion had a shorthand notation.
~~Proposition: `@"\n"(command)`, where "\n" can be any arbitrary separator.~~
This could cause confusion with methods, where `@join(command)` and `@"join"(command)` behave fairly differently. Further more, this would not allow expansion and/or would make it awkward (ex: `@"$var"(command)`)unplannedhttps://gitlab.redox-os.org/redox-os/ion/-/issues/819demon threads don't work to launch gui on linux2019-07-09T18:46:36Zmattdemon threads don't work to launch gui on linuxI'm using manjaro linux. and whenever I try to write something like
geany &
or some other gui program, the thread stops, and the program doesn't run.
If I run without & it runs, and if I demonise a non gui thread it runs happily.
...I'm using manjaro linux. and whenever I try to write something like
geany &
or some other gui program, the thread stops, and the program doesn't run.
If I run without & it runs, and if I demonise a non gui thread it runs happily.
I'd like to be able to push ^d to be able to quit the terminal while the demon is running and have it still running.https://gitlab.redox-os.org/redox-os/ion/-/issues/818cargo install ion2020-12-12T23:18:13ZSquirrelcargo install ionWould be lovely if cargo install ion worked just like cargo install bat or cargo install ripgrep works.
Then I could just type ion and run the shell.
(Liking your work, trying to use it as main shell)Would be lovely if cargo install ion worked just like cargo install bat or cargo install ripgrep works.
Then I could just type ion and run the shell.
(Liking your work, trying to use it as main shell)Ion Shell v1.0.0https://gitlab.redox-os.org/redox-os/ion/-/issues/813Ion shell isn't recognised as a shell2021-06-01T11:54:50ZJonathan TurnerIon shell isn't recognised as a shellAssuming I typed this right, it looks like ion shell isn't recognised by Ubuntu as a valid shell to `chsh` to. Would be great if it was, so more folks could use it more regularly.
![image](/uploads/99e19d4a1daa42e19bd93eb2e6aafc7e/image...Assuming I typed this right, it looks like ion shell isn't recognised by Ubuntu as a valid shell to `chsh` to. Would be great if it was, so more folks could use it more regularly.
![image](/uploads/99e19d4a1daa42e19bd93eb2e6aafc7e/image.png)https://gitlab.redox-os.org/redox-os/ion/-/issues/807Partial glob2021-06-01T11:58:06ZСухарикPartial globToday I wrote the following line:
```
for f in *.pdf; convert -density 150 $f"[0]" -flatten $filename($f).png; end
```
This works fine, right? But there's a problem. A file extension can have more than one level (for example, `foo.user...Today I wrote the following line:
```
for f in *.pdf; convert -density 150 $f"[0]" -flatten $filename($f).png; end
```
This works fine, right? But there's a problem. A file extension can have more than one level (for example, `foo.user.js`), so in general case `$filename` is not sufficient.
Instead of using ad-hoc functions, it would be nice to have a glob deconstructed into several parts. So you could so something like
```
for (n, e) in (*).({bmp,gif,png})
convert $n.$e $n.jpg
end
```
So globing is more like pattern matching.https://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/645Tab width not respected2020-04-22T00:18:35ZMichael Aaron Murphymmstick@pm.meTab width not respected*Created by: ideasman42*
Using Linux, In a directory with many files run:
```
tabs -4; ls
```
Columns aren't aligned correctly, running `tabs -8; ls` shows as expected.*Created by: ideasman42*
Using Linux, In a directory with many files run:
```
tabs -4; ls
```
Columns aren't aligned correctly, running `tabs -8; ls` shows as expected.https://gitlab.redox-os.org/redox-os/ion/-/issues/566Control Flow Redirections?2020-12-12T23:48:33ZMichael Aaron Murphymmstick@pm.meControl Flow Redirections?Should control flow keywords be able to perform and work with redirections themselves?
```sh
for x in 1...10
echo $x
end > results.txt
```
And a theoretical `map` keyword that works similar to `for`, but reads from stdin:
```sh
ca...Should control flow keywords be able to perform and work with redirections themselves?
```sh
for x in 1...10
echo $x
end > results.txt
```
And a theoretical `map` keyword that works similar to `for`, but reads from stdin:
```sh
cat results.txt | map x
echo $x
end
```
And combined:
```sh
for x in 1...10
echo $x
end | filter x
ends-with 5 $x
end | map x
echo $x
end
```
```Ion Shell v1.0.0https://gitlab.redox-os.org/redox-os/ion/-/issues/556$escape() and $unescape() methods2018-06-12T14:22:02ZMichael Aaron Murphymmstick@pm.me$escape() and $unescape() methodsEssentially, Bash allows one to convert ASCII sequences into their corresponding codes if that string is enclosed within single quotes that follow the `$`.
```bash
echo $'this\nstring\thas\tspecial\ncodes'
```
```
this
string h...Essentially, Bash allows one to convert ASCII sequences into their corresponding codes if that string is enclosed within single quotes that follow the `$`.
```bash
echo $'this\nstring\thas\tspecial\ncodes'
```
```
this
string has special
codes
```
We should support this with an `$unescape()` method, like so:
```sh
echo $unescape('this\nstring\thas\tspecial\ncodes')
```
As well as a corresponding `$escape()` method that will do the opposite. We could likely re-use logic from the `echo` builtin to do this.https://gitlab.redox-os.org/redox-os/ion/-/issues/511Match Statement Enhancements2018-06-12T14:22:02ZMichael Aaron Murphymmstick@pm.meMatch Statement Enhancements# Match Binds
We should do as Rust and other languages and support the ability to bind the result of the expression given to a match statement so that there is no requirement to manually store a temporary value via `let`.
```ion
m...# Match Binds
We should do as Rust and other languages and support the ability to bind the result of the expression given to a match statement so that there is no requirement to manually store a temporary value via `let`.
```ion
match ${git::branch}
case ""; echo No branch found
case _ @ result; echo Found $result
end
```
We may even want to make it possible to elide the '_' on the above expression:
```
case @ result; echo Found $result
```
# Conditional Checks
We should also support a means of performing an extra in-line conditional check on a given case. Perhaps the `?` operator would make that easier to read? Or should we use the standard 'if'?
```ion
match ${git::branch}
case @ result if exists $result; echo Found $result
case "master" if test -z $other; echo Found master branch and $other
end
```
```ion
match ${git::branch}
case @ result ? exists $result; echo Found $result
case "master" ? test -z $other; echo Found master branch and $other
end
```https://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/480Function Scopes & Namespaces2020-12-13T00:44:04ZMichael Aaron Murphymmstick@pm.meFunction Scopes & NamespacesI think it'd be a good idea if functions had their own scopes, and whereby the user can request variables from a higher scope, albeit I wonder if it'd be better to just have a `global` scope and no upper scopes.
```ion
let var1 = "fi...I think it'd be a good idea if functions had their own scopes, and whereby the user can request variables from a higher scope, albeit I wonder if it'd be better to just have a `global` scope and no upper scopes.
```ion
let var1 = "fizz"
fn parent
let var2 = "buzz"
fn child
let var3 = "bazz"
# Access global scope (highest level)
echo ${global::var1}
# Access the next scope up
echo ${super::var2}
# Access two scopes up
echo ${super::super::var1}
# Ensure access to current scope only
echo ${local::var3}
# Ensure access to environment variable
echo ${E::PATH}
end
child
end
parent
```
jD91mZM2jD91mZM2https://gitlab.redox-os.org/redox-os/ion/-/issues/471Support De/Serialization & Functional Pipelines Like Elvish?2021-06-01T11:27:18ZMichael Aaron Murphymmstick@pm.meSupport De/Serialization & Functional Pipelines Like Elvish?It should be possible for us to provide some builtin commands that can handle de/serialization of text, similar to what the Elvish shell is doing. No reason to let Elvish have an advantage over Ion! Could really use some insight from tho...It should be possible for us to provide some builtin commands that can handle de/serialization of text, similar to what the Elvish shell is doing. No reason to let Elvish have an advantage over Ion! Could really use some insight from those who are more familiar with this sort of concept. This is my take on how we could achieve it.
Note that this could be an optional feature in order to keep the file size of Ion's binary small, if implementing this would increase file size too much.
# Issue Dependencies
This would require builtin pipeline execution and associative arrays before it could be implemented.
- #246 : Associative Arrays
- #379 : Builtin Pipeline Execution
# How It Might Work
1. We could have builtin commands that can parse specific formats, such as `from-json`
2. Those commands would deserialize the format into our native associated array syntax
3. We could also provide a `select` builtin which reads from stdin and has a SQL-ish syntax
4. And then an `each` builtin which also reads from stdin, and evaluates expressions with arguments supplied on each line fed to stdin.
4. ???
5. Profit
# Examples
Here's a JSON example:
```json
{"colors": [
{ "name": "red", "value": "F00" },
{ "name": "blue", "value": "00F" },
]}
```
## Example 1
```sh
$ wget <JSON_FILE> | from-json
```
```
&colors=[{&name='red' &value='FOO'} {&name='blue' &value='00F'}]
```
## Example 2
```sh
wget <JSON_FILE> | from-json |
select all from colors
```
```
&name='red' &value='FOO'
&name='blue' &value='00F'
```
## Example 3
```sh
wget <JSON_FILE> | from-json |
select all from colors |
each 'echo color={name} value={value}'
```
```
color=red value=F00
color=blue value=00F
```
## Example 4
```sh
wget <JSON_FILE> | from-json |
select value from colors where name = red
```
```
$='FOO'
```
## Example 5
```sh
wget <JSON_FILE> | from-json |
select name, value from colors where name = red
```
```
$='red' $='FOO'
```
## Example 6
```sh
wget <JSON_FILE> | from-json |
select name, value from colors where name = red |
each 'echo color={0} value={1}'
```
```
color=red value=F00
```
## Example 7
```sh
wget <JSON_FILE> | from-json |
select name, value from colors where name = red |
each 'echo color={name} value={value}'
```
```
color=red value=F00
```unplannedhttps://gitlab.redox-os.org/redox-os/ion/-/issues/472Multiple Indices?2018-06-14T12:44:09ZMichael Aaron Murphymmstick@pm.meMultiple Indices?Perhaps we can poach this idea from Elvish?
```ion
$ let array = [1 2 3 4 5 6 7 8 9 10]
$ echo @array[0 1 7..]
1 2 8 9 10
```Perhaps we can poach this idea from Elvish?
```ion
$ let array = [1 2 3 4 5 6 7 8 9 10]
$ echo @array[0 1 7..]
1 2 8 9 10
```stratactstratact1@gmail.comstratactstratact1@gmail.comhttps://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/439Possible Algebraic Data Types / Enum Support?2021-06-01T11:58:08ZMichael Aaron Murphymmstick@pm.mePossible Algebraic Data Types / Enum Support?Another feature that would give Ion an advantage is to support algebraic data types / enums. We just need to figure out a syntax that would make sense for a shell language. Here's an example of how it might look like.
```sh
# Create an ...Another feature that would give Ion an advantage is to support algebraic data types / enums. We just need to figure out a syntax that would make sense for a shell language. Here's an example of how it might look like.
```sh
# Create an enum pattern
enum Action = Withdraw(amount:int) Deposit(amount:int)
while true
echo -n "Enter the action to perform"; read input
match input
case 1
echo -n "Enter amount to withdraw: "; read amount
# Assign a variable that is an enum
let action:enum = Action:Withdraw($(ftoi $amount -d 2))
break
case 2
echo -n "Enter amount to deposit: "; read amount
# Assign a variable that is an enum
let action:enum = Action:Deposit($(ftoi $amount -d 2))
break
case 3; echo "Exiting"; exit
case _; echo "Invalid Input"
end
end
# Match on a pattern that represents an enum
# Requires that all variants are handled
match action:enum
case Withdraw(amount)
echo "Withdrawing $amount"
case Deposit(amount)
echo "Withdrawing $amount"
end
```
No reason to not go the extra mile in creating a next-gen *nix shell.unplannedhttps://gitlab.redox-os.org/redox-os/ion/-/issues/414Make End Keyword In Case Statements Optional2018-06-12T14:22:03ZMichael Aaron Murphymmstick@pm.meMake End Keyword In Case Statements OptionalThis is what Fish does, as the `case` keyword already denotes that a new case block is being specified, so I'm not sure I see the value in requiring the end keyword to end a case.This is what Fish does, as the `case` keyword already denotes that a new case block is being specified, so I'm not sure I see the value in requiring the end keyword to end a case.