News for hackers. Stuff that matters.
Re:Nushell 0.60 Released by orf on Wednesday March 23, 2022 @09:19AM (#30778151)
I really like the idea of Nushell.

  > /Users/tom> ps | grep "k9"
  Unsupported: Row(Dictionary { entries: {"pid": Value { value: Primitive(Int(359)), tag: Tag { anchor: None, span: Span { start: 3, end: 5 } } }, "name": Value { value: Primitive(String("backupd-helper")), tag: Tag { anchor: None, span: Span { start: 3, end: 5 } } }, "status": Value { value: Primitive(String("Unknown(0)")), tag: Tag { anchor: None, span: Span { start: 3, end: 5 } } }, "cpu": Value { value: Primitive(Decimal(BigDecimal("0.000000000000000"))), tag: Tag { anchor: None, span: Span { start: 3, end: 5 } } }, "mem": Value { value: Primitive(Filesize(0)), tag: Tag { anchor: None, span: Span { start: 3, end: 5 } } }, "virtual": Value { value: Primitive(Filesize(0)), tag: Tag { anchor: None, span: Span { start: 3, end: 5 } } }} })
  error: Received unexpected type from pipeline (row)
    ┌─ shell:2:6
    │
  2 │ ps | grep "k9"
    │      ^^^^ expected a string, got row as input
I understand what happened here, but sometimes I really want to just grep through stuff. It's not clear how to do this and there isn't much in the docs about it. Without this I'm not sure I could actually switch.
Re:Nushell 0.60 Released by ripley12 on Wednesday March 23, 2022 @11:01AM (#30779162)
Hi, the `find` command is probably easiest: https://www.nushell.sh/book/commands/find.html

ps | find k9

That will search through every column in the `ps` results. If you want to look through just the name column:

ps | where name =~ k9

Re:Nushell 0.60 Released by nerdponx on Wednesday March 23, 2022 @11:12AM (#30779279)
Is there a command to string-ify the input so that you can use standard Unix coreutils, etc. on it?

This was always my big annoyance with Powershell too, the shell builtins and functions were powerful, but interacting with "dumb" old-style programs that expect and emit streams of text was cumbersome.

Also, is `ps` here a wrapper or shell builtin? Or is Nushell actually parsing the output from the `ps` program?

Re:Nushell 0.60 Released by ripley12 on Wednesday March 23, 2022 @11:33AM (#30779523)
ps is a shell builtin in Nu (and you can check that with `which ps`).

Going from Nu to raw text is currently a little awkward. `str collect (char nl)` will take a Nu list of strings and convert it to raw text with line breaks. I suspect we'll get a more ergnomic way to do this soon.

Going to Nu from raw text is nicer, the built-in `lines` command splits line-break-delimited text into a list of strings. From there you can use lots of Nu tools to operate on each line.