News for hackers. Stuff that matters.
Re:Marcel the Shell by geophile on Monday October 23, 2023 @06:27PM (#37992466)
I wrote marcel. In my view, nushell and marcel are very similar. nushell has tabular output, which I haven't thought was all that useful.

Marcel is python-based. The nushell guys have had to invent a lot of language. By basing marcel on python, I don't have to invent language. Any logic to be added is expressed in python. E.g, do a recursive listing of files and find those that changed in the last 3 days:

    ls -fr | select (f: now() - f.mtime() <= days(3))
The stuff inside the parens is a python function, applied to a File f, piped in from ls. (Marcel lets you omit "lambda".)

Lots of marcel examples here: https://marceltheshell.org

Re:Marcel the Shell by mito88 on Monday October 23, 2023 @07:11PM (#37992852)
marshell the cell....

sorry couldn't resist.

:)

Re:Marcel the Shell by geophile on Monday October 23, 2023 @07:12PM (#37992868)
Marcel is open source, so no.
Re:Marcel the Shell by mito88 on Monday October 23, 2023 @07:14PM (#37992876)
I meant cell.
Re:Marcel the Shell by geophile on Monday October 23, 2023 @07:26PM (#37992987)
But … but it’s a shell!
Re:Marcel the Shell by mito88 on Monday October 23, 2023 @07:35PM (#37993069)
shure, of course.

OK, enough!

( ´ー`) (  ̄ー ̄)ノ

Re:Marcel the Shell by js2 on Monday October 23, 2023 @07:42PM (#37993127)
This looks interesting, but the examples don't really show off Marcel's power. The example you just gave without Marcel is:

  find . -type f -mtime -3
The example on this page: https://www.marceltheshell.org/list-processes

  ps -u djt | map (p: p.signal(9))
That's:

  pkill -9 -u djt
The example for summing files by extension is a bit more interesting:

  ls -fr | map (f: (f.suffix, 1)) | red. + | sort
Vs something like:

  find . -type f | awk -F. '(NF>1){print "."$NF}; (NF==1){print ""}' | sort | uniq -c
That said, every time I look into one of these shells, I end up sticking with bash. When it gets to the point that I need something more powerful than bash and the Unix command line environment, I'd just as soon write a stand-alone program which I can check into version control, use on remote systems that don't have one of these fancy shells installed, add proper tests, etc.

This is a neat project though. I'll keep an eye on it.

Re:Marcel the Shell by geophile on Monday October 23, 2023 @07:59PM (#37993259)
I actually agree with most of this. I tend to use Marcel for ETL sorts of processing, quick database access with data munging on either side, cluster access, etc. it works fine for basic shell usage though.

As for a more complex example: yes, the website has better examples, but they are also more involved to explain.

Re:Marcel the Shell by geophile on Monday October 23, 2023 @08:01PM (#37993279)
Almost forgot: I also switch from bash to Python at a low threshold. In that case, I find Marcel’s API useful. I can then do shell-like piping inside of Python.
Re:Marcel the Shell by Too on Tuesday October 24, 2023 @01:04AM (#37994989)
Using the output of find into another program is not safe due to risk of file names containing delimiters. You need to use find -exec.

Good example of why machine readable output is important. Agree that the tutorial should showcase more and larger such examples.

Re:Marcel the Shell by rmwaite on Tuesday October 24, 2023 @01:09AM (#37995016)
You can always use -print0. I suppose there is some risk of a null slipping into a filename but I’ve never come across it myself.
Re:Marcel the Shell by gnosek on Tuesday October 24, 2023 @01:28AM (#37995095)
> some risk of a null slipping into a filename

Only in some fairly esoteric environments: https://en.wikipedia.org/wiki/Filename#Comparison_of_filenam...

Re:Marcel the Shell by js2 on Tuesday October 24, 2023 @01:51AM (#37995222)
Yes, I know that, but it's also exceedingly rare for a filename to contain a newline and using -exec is extremely inefficient. I also wrote that on my iPad. Typically I'd use a combination of -print0 and xargs -0 for anything more formal than a one-liner on the command line.

The larger bug in my example is that it fails if any of the directories in the path contain a "." in their name!

Re:Marcel the Shell by eviks on Tuesday October 24, 2023 @03:18AM (#37995724)
So then why are you using such buggy examples as counterarguments?
Re:Marcel the Shell by js2 on Tuesday October 24, 2023 @04:02AM (#37996021)
It's one example. I didn't realize the mistake when I wrote it. I wrote my comment in good faith. What's with the interrogation?
Re:Marcel the Shell by queuebert on Tuesday October 24, 2023 @09:29AM (#37998922)
xargs also is good to use on big argument lists because it can parallelize the processing of arguments with the '-n' and '-P' flags.
Re:Marcel the Shell by prometheon1 on Tuesday October 24, 2023 @01:53AM (#37995232)
In that case, is it even more similar to xonsh?

https://xon.sh/

Re:Marcel the Shell by geophile on Tuesday October 24, 2023 @09:43AM (#37999085)
I posted a comparison to xonsh elsewhere in this discussion.
Re:Marcel the Shell by lars512 on Tuesday October 24, 2023 @04:58AM (#37996467)
Marcel looks really interesting.

As someone who's leaned into Nushell deeply, I can tell you that the tabular and hierarchical data output is the major selling point of Nushell. For me and my team, who work with data and metadata constantly, it's an incredible productivity boost.

The major pains with Nushell are debugging pipelines that are too slow, having to learn the new language constructs, and process overhead for going in and out of Python for other pieces.

Re:Marcel the Shell by geophile on Tuesday October 24, 2023 @11:31AM (#38000560)
If you stick to marcel commands and python functions, then all the processing happens in a single Python process (with a small number of exceptions). Beside the process overhead, this approach also avoids serialization/deserialization costs, and even string copying costs. x | y | z just passes Python tuples from one command to another via function call.

Can you expand on your first point? Why are tabular and hierarchical output so important for your work?