Live data from Hacker News

Elvish – Scripting language and interactive shell

github.com

31–40 of 62 posts

Re: Elvish – Scripting language and interactive shell

#31
I've been eyeing a "better shell" for a while, but I've just decided that a couple zsh plugins and I'm probably happiest. As the meme says "Change my mind".

I've been using fish for the last year or more, and I like some of the "batteries included", particularly the predicting of the command you want to run. But fish is too much like bash in syntax, meaning that I just think of it like bash until I have to type "(foo)" instead of "$(foo)", or "end" instead of "fi". The zsh plugins for doing command predicting and fancy prompt seems to get me all the fish benefits with none of the rough spots. And, frankly, the changes fish does doesn't seem to have any benefit (what is the benefit of "end" over "fi").

Even xonsh (I'm a huge Python fan) doesn't really have enough pull for me to stick in it. Oils, nu, elvish, they all have some benefits for scripting, but I can't see myself switching to them for interactive use.

It's kind of feeling like zsh is "good enough" with no real downsides. Maybe this is mostly that I've been using sh/ksh/bash/zsh for 40 years, some of these other shells might be easier to switch to if you lack the muscle memory?

Re: Elvish – Scripting language and interactive shell

#32
post #17

I went down this route based on HN recommendations, with some people calling it stable well documented. There's TODOs all over the documentation! There's no background task tools for scripting, and in interactive use background tasks are barely supported - an issue about background tasks has people going roughly "nobody needs to do tasks in parallel, that was only important when people were working on mainframes". Th…

it's still under development, but it most certainly isn't dead. it's stable in that development is not disruptive. i use it as a daily driver.

you are right about lack of support for job control, it's annoying. but my understanding is that the problem seems to be a difficulty in implementing job control with go. when people say nobody needs parallel tasks that doesn't make sense because you can run jobs in the background. you just have to do it explicitly before starting, and you can't switch back and forth. yes, that's a problem, and for me it is one of the most annoying missing features. but it comes up seldom enough that it doesn't disrupt daily use for me. which is to show that the things i need for daily use are all there.

Re: Elvish – Scripting language and interactive shell

#33
post #22

Earlier quoted context omitted.

Not even that matters to me: I will install from repos. It might make packagers' lives a bit more difficult in some cases but they are probably very familiar with that. I have not really had problems with installing C (on the rare occasions I have compiled anything of any complexity) nor Python applications. Xonsh is supposed to be pretty good and written in Python, and most existing shells (bash, zsh, csh etc.) are…

Fish switched from C++ to Rust really recently. https://fishshell.com/blog/rustport/

That is impressive.

Now you mention it I vaguely recall reading something about it somewhere as planned but its been done!

Re: Elvish – Scripting language and interactive shell

#34
post #27
post #23

Earlier quoted context omitted.

There’s also a lot of good design that’s gone into Elvish. And I don’t think it’s fair to call it “dead” when the maintainers for Elvish are active both on Github and here on HN too (probably other places too). However if you’re looking for an alternative then there’s: - Murex (disclaimer: I’m one of the maintainers) which does support background processes and has extensive documentation. https://murex.rocks - Nushel…

Elvish had some very cool ideas, which is why I tried it out! Like the built in script checker! But it also has a lot of very basic issues that have been open for years, and TODOs in the documentation as I mentioned. People are going to read your message and put N hours into it and get burned, and I think this is a fair warning. Nushell also had very minimal background task support, so I rejected that. They explicitl…

> does `bg` return the `fid`

There's two kinds of process IDs in Murex: FID (function IDs) and PID (process IDs)

Forking is expensive in POSIX and has a number of drawbacks such as the inability to share scoped variables without resorting to environmental variables. So a FID is basically a PID but managed inside the scope of Murex's runtime. You can manage FIDs in much the same way as you can manage PIDs, albeit using Murex builtins rather than coreutils (though PID management tools in Bash are technically builtins rather than coreutils too).

What this means in practice is you can have entire blocks of code pushed into the background, eg

    » GLOBAL.name = "rendaw"
    » bg { sleep 5; echo "Hello $name" }; echo "not bg"
    not bg
    Hello rendaw
You can see the FID as well as the job ID the usual way, via `jobs`

    » jobs
    JobID  FunctionID  State      Background  Process  Parameters
    %1     2109        Executing  true        exec     sleep 5
...and you can kill that entire `bg` block too

    fid-kill 2109
But you'd also see any non-builtins in `ps` too:

    » ps aux | grep sleep
    hnlmorg   72749   0.0  0.0 410743712   1728 s012  S+    4:24p.m.   0:00.00 /usr/bin/grep --color=auto sleep
    hnlmorg   72665   0.0  0.0 410593056    432 s012  S+    4:23p.m.   0:00.00 /bin/sleep 5

> Can you use those in scripts, or are they hobbled the same way bg/fg are in bash?

While the above seems very complicated, the advantage is that `bg` and `fg` become much more script friendly.

> - System-wide config file, I use Nixos and manage my system config using that

This isn't Murex's default behaviour but you could easily alter that with environmental variables: https://murex.rocks/user-guide/profile.html#overriding-the-d...

The latest version of Murex (v7.0.x), which is due to be released in the next few days, makes this even easier with a $MUREX_CONFIG_DIR var that can be used instead of multiple specific ones.

> - Background task support - I need to start an ssh tcp proxy, pipe a command over it, then kill ssh once the command is done (all in a script).

Murex has another layer of support for piping in addition to those defined in POSIX, which are basically channels in the programming language sense. In murex they're called "Murex Named Pipes" but the only reason for that is that they can be used as a glue for traditional POSIX pipes too. This is one area where the documentation could use a little TLC: https://dev.murex.rocks/commands/pipe.html

> - Post-command hook, to send a notification when a long command finishes

There are two different events you can hook into here:

- onPrompt: https://dev.murex.rocks/events/onprompt.html

This is similar to Bash et al prompt hooks

- onCommandCompletion: https://dev.murex.rocks/events/oncommandcompletion.html

This hooks into any command name that's executed. It runs the comment in a new TTY and buffers the command's output. So, for example, if you want a command like `git` to automatically perform a task if `git push` fails with a specific error message, then you can do that with onCommandCompletion.

> - Async iteration of command output, i.e. streaming events with swaymsg subscribe and running a command when certain events occur

I'd need to understand this problem a little more. The channels / Murex Named Pipes above might work here. As might onCommandCompletion.

> - Value/call arity safety - i.e. a clear distinction between a single value and multiple values that doesn't rely on stringification hacks. I.e. in `command $x` `command` should always have one argument, regardless of the contents of `x`, and making that plural should be explicit.

This one is easy: scalars are always $ prefixed whereas arrays are @ prefixed. So take the following example:

    array = %[ a b c ]
    
    » echo $array
    ["a","b","c"]  # a single parameter representation of the array

    » echo @array
    a b c          # the array expanded as values
-----

This is quite a lengthy post but hope it helps answer a few questions

Re: Elvish – Scripting language and interactive shell

#35

I've been eyeing a "better shell" for a while, but I've just decided that a couple zsh plugins and I'm probably happiest. As the meme says "Change my mind". I've been using fish for the last year or more, and I like some of the "batteries included", particularly the predicting of the command you want to run. But fish is too much like bash in syntax, meaning that I just think of it like bash until I have to type "(foo…

> But fish is too much like bash in syntax, meaning that I just think of it like bash until I have to type "(foo)" instead of "$(foo)", or "end" instead of "fi"

Note that fish does also support bash's "$(foo)" syntax and has for a few years now.

Re: Elvish – Scripting language and interactive shell

#36

I've been eyeing a "better shell" for a while, but I've just decided that a couple zsh plugins and I'm probably happiest. As the meme says "Change my mind". I've been using fish for the last year or more, and I like some of the "batteries included", particularly the predicting of the command you want to run. But fish is too much like bash in syntax, meaning that I just think of it like bash until I have to type "(foo…

What plugins? And where is your zsh config?

(Ftr, I've been using zsh for maybe 5-8 years, managed to avoid oh-my-zsh, and only use 'zsh-autosuggestions' and 'zsh-syntax-highlighting' plugins. I've customised a theme to suit me, but barely know anything about zsh to be honest...)

Re: Elvish – Scripting language and interactive shell

#37
post #35

I've been eyeing a "better shell" for a while, but I've just decided that a couple zsh plugins and I'm probably happiest. As the meme says "Change my mind". I've been using fish for the last year or more, and I like some of the "batteries included", particularly the predicting of the command you want to run. But fish is too much like bash in syntax, meaning that I just think of it like bash until I have to type "(foo…

> But fish is too much like bash in syntax, meaning that I just think of it like bash until I have to type "(foo)" instead of "$(foo)", or "end" instead of "fi" Note that fish does also support bash's "$(foo)" syntax and has for a few years now.

Ooh, good to know!

Re: Elvish – Scripting language and interactive shell

#38
post #36

I've been eyeing a "better shell" for a while, but I've just decided that a couple zsh plugins and I'm probably happiest. As the meme says "Change my mind". I've been using fish for the last year or more, and I like some of the "batteries included", particularly the predicting of the command you want to run. But fish is too much like bash in syntax, meaning that I just think of it like bash until I have to type "(foo…

What plugins? And where is your zsh config? (Ftr, I've been using zsh for maybe 5-8 years, managed to avoid oh-my-zsh, and only use 'zsh-autosuggestions' and 'zsh-syntax-highlighting' plugins. I've customised a theme to suit me, but barely know anything about zsh to be honest...)

Well, pretty much what you said: syntax-highlighting, oh-my-zsh, git, command-not-found, autosuggestions, atuin, zoxide, and zsh-vi-mode. These days, I'm looking for as little stuff that I have to maintain myself as possible.

Re: Elvish – Scripting language and interactive shell

#39
post #17

I went down this route based on HN recommendations, with some people calling it stable well documented. There's TODOs all over the documentation! There's no background task tools for scripting, and in interactive use background tasks are barely supported - an issue about background tasks has people going roughly "nobody needs to do tasks in parallel, that was only important when people were working on mainframes". Th…

The big one for me is no string interpolation, as a deliberate design choice.

what can string interpolation do that i can't also do by sandwiching a variable between strings: 'string1'$var'string2'?

string interpolation is useful where concatenating strings requires an operator, but i don't see the benefit otherwise.

for more complex examples i can use printf, or someone could write a function that does string interpolation. since there is no need to fork, that should not be that expensive

Re: Elvish – Scripting language and interactive shell

#40
I've been using fish for many years now though I keep trying all these new shells.

Ultimately I've found that for my interactive shell I just want something widely supported and with easy syntax for `if` and `for` loops for short multi-line commands. For anything longer than that I just reach for real Python using either the `sh` or `plumbum` package.

I don't need the extra features very often, so I just run things in full Python where I'm already comfortable.

I've tried oils/ysh, elvish, xonsh, nushell, and while they are _fine_ I don't want to learn a different language that's not quite Python and not quite shell.

Post reply on HN