Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Patrick
@PatrickF1
btw https://fishshell.com/docs/current/language.html#future-feature-flags says "round of escaping", but that should read "round of unescaping right"?
Fabian Boehm
@faho
Please read the linked issue. It was simply a mistake in the original implementation.
"un"escaping is a pretty technical term, it's when you turn $ into "expand this" and \$ into $. If it does too much unescaping that means you need more escaping. I do not believe this subtlety helps any in the explanation, so we've left it as "escaping".
Peter Ammon
@ridiculousfish
fish shell is on the orange site once again, lots of nice comments about it
David Adam
@zanchey
some nice comments on HN re: fish today
Jim Richardson
@weaselkeeper
tried fish today as result of reading about it in
HN
had avoided it for a while due to non-posix
hard to step out of decades of relying on posix shells...
Johannes Altmanninger
@krobelus
@weaselkeeper it's POSIX enough for lots of interactive scenarios
Jim Richardson
@weaselkeeper
yeah, focusing on it as an interactive shell, probably stick with bash/sh for scripting, but I do more and more of that in python these days than shell anyway.
If it's going to take more than a few lines/functions, it's getting done in python or a DSL instead of bash
Juan Patten
@jrpat
brand new fish user here. I want to check if a tmux session is running, without outputting anything to the shell. in bash, I do [ -n "$(tmux ls | grep foo)" ] && ... - In fish, the way seems to be set x (tmux ls | grep foo) ; if test $status -eq 0 ...
is there a better way?
Fabian Boehm
@faho

@jrpat If you're just interested in the exit status, simply put the command into the if-condition:

if tmux ls | grep foo

to ignore the output you'd usually redirect it to /dev/null (with the old >/dev/null), but in this case grep has a -q switch:

if tmux ls | grep -q foo

If you also want the output, you can still use the set:

if set x (tmux ls | grep foo)

set doesn't set the status itself and simply passes on whatever the command substitution returned.

Juan Patten
@jrpat
ah ok - very helpful. yeah it's nice that grep has a -q, but I also wondered about the general case when a command doesn't have a quiet flag. >/dev/null it is. thanks!
Subsentient
@Subsentient
Is there a good way to get the index of a particular occurence of a pattern in a string? Like Python's 'derp'.find('e')
Peter Ammon
@ridiculousfish
@Subsentient try e.g. string match --index --regex foo bigfoot, it will show the range of the regex match.
schuelermine
@schuelermine:matrix.org
[m]
Is it fish-specific or a general cross-shell convention that redirections are processed right-to-left?
i.e. cmd 2>&1 >file doesn’t redirect stderr to file, but cmd >file 2>&1 does
David Adam
@zanchey
hmm, the notifiers test seems a bit flaky
Peter Ammon
@ridiculousfish
@schuelermine:matrix.org redirections are processed left to right. 2>&1 means "stdout is dup'd to stderr" and >file means "file is dup'd to stdout". So in 2>&1 >file you end up with stderr as the original stdout, and stdout as the file.
2 replies
Aaron Gyes
@floam
I agree, and do miss --authoritiative; but I wish it were a bit easier to specify flags that can be used only n times and/or only with certain other options.
Peter Ammon
@ridiculousfish
All shells process redirections left to right AFAIK. The only divergent case is mixing a stdout redirection with a pipe.
Aaron Gyes
@floam
the conditionals I used in my few minutes ago completion commit kinda stink.
Peter Ammon
@ridiculousfish
Generating completions is an inherently messy process. I sometimes complete and intend to go back and fix up the command line later. Plus we have so much pain dealing with divergent implementations of utilities already, now imagine trying to encode all the divergent DSLs on top of that...yuck.
schuelermine
@schuelermine:matrix.org
[m]
Oh, I guess I mis-wrote
schuelermine
@schuelermine:matrix.org
[m]
OK
it just seems rather unintuitive is all
Aaron Gyes
@floam
some commands can be fully specified - like our builtins for example.
Peter Ammon
@ridiculousfish
Yeah, it feels backwards, huh. The syntax >file looks like "redirect the stdout stream to a file", but under the hood it's "throw away whatever stream is associated with stdout, and replace it with this file."
Streams don't have descriptors; a descriptor has a stream.
Aaron Gyes
@floam
hm
all streams have a descriptor, fileno() will tell it.
Peter Ammon
@ridiculousfish
By "stream" I don't mean FILE * which is just a libc thing, I mean the underlying kernel resource.
Aaron Gyes
@floam
maybe we could do something to make pipes and redirections more obvious, like highlighting the extent when the cursor is on the operator.
David Adam
@zanchey
ridiculousfish, that's a really interesting conceptualisation, had never occurred to me (but the backwardsness certainly had)
Subsentient
@Subsentient
How open is Fish to additional commands via a PR? In particular, I have some additions to the string subcommand in mind.
David Adam
@zanchey
we'd certainly consider them
if there's a lot of work involved you might want to open an issue to discuss the proposed design
Emily Grace Seville
@EmilySeville7cfg
How to scroll completion descriptions left/right?
David Adam
@zanchey
I don't think you can, you have to resize your window to see more
Emily Grace Seville
@EmilySeville7cfg
My screen sometimes is too small for some descriptions ;)
David Adam
@zanchey
yes, I know what you mean. we were trying to keep them fairly short for most commands but it's not always easy
Thom Chiovoloni
@thomcc
if exit is used in a function, is that the same as return (i assume not but it would be nice, although thinking more i can see many reasons why it shouldn't be)
i guess really what i want is an easy way to "print a message to stderr, and exit return a status to the caller". i find myself writing this often, and because i can't return from the caller (nor would i really want that) i can't really encapsulate it
Thom Chiovoloni
@thomcc
that said a significant portion of why i want this is despite having used fish heavily for years now, i have to look up the syntax for printing to stderr every single time
Fabian Boehm
@faho
@thomcc exit in a function executed inside the shell exits the shell. exit inside a script exits the script.
Basically it jumps to the nearest source.