Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Aaron Gyes
@floam
I had to chmod 000 1 & chmod 000 2 to make sure I wasn't fucking it up.
but my memory is weird.
Aaron Gyes
@floam
is it just me or is __fish_complete_suffix broken?
image.png
kaddkaka
@kaddkaka:matrix.org
[m]
When can I expect an impish release of fish? (https://launchpad.net/~fish-shell/+archive/ubuntu/release-3/+packages)
oooh, there is an impish release, but the file is named hirsute
Subsentient
@Subsentient
Can someone explain to me how the "or" modifier executes at all when it's not part of the conditional itself, but rather a member of the block to execute? That block should never be entered because the first test condition just failed, so how is "or" working?
Fabian Homborg
@faho
@Subsentient You might have more luck with some example code.

In lieu of that, here's how or works:

In the simple case:

foo
or bar

if foo failed, fish moves on to the or, which checks $status. This is similar to

foo
if test $status -ne 0
    bar
end

This is all very easy and fine and dandy, there is however a special case. In if or while conditions, the or binds the command to the condition instead of going into the block:

if foo; or bar
    echo hello
end

will print hello if foo succeds, and will also print hello if foo fails and the subsequent bar succeeds. If both foo and bar fail, it won't print.

This isn't 1000% clean, but the alternative of making or just that simple shortcut is that you now need to write

if begin; foo; or bar; end

which is just annoying (and yes, that used to be the case up to fish ~2.3)

Fabian Homborg
@faho

I'm assuming you meant the latter by "member of the block to execute", and so the answer is: Because it was annoying otherwise, so we changed it.

Because the other behavior might be "clean" from a theoretical standpoing, but also 100% useless:

if foo
    if test $status -ne 0
        bar
    end
   echo hello
end

Here, to get to the bar, foo would have to fail. But once it fails the if-block won't be entered anymore, so that bar is unreachable! It can't be used! It's dead!

Subsentient
@Subsentient
Damn, I really, really don't like that. Just a suggestion, but if it were me, I'd deprecate that usage of or in an if conditional with the semicolon preceding, and either A. Add documented syntax for 'or' used there without a semicolon, or B. move to || as the supported method. >.<
Subsentient
@Subsentient
I do want to say, however, that I'm very appreciative of Fish shell. Please make sure that this project flourishes. I never liked old shell script, too many bizarre edge cases and strange behaviors. With Fish I'm finally comfortable writing complex shell scripts without feeling that sinking feeling that something somehow isn't quoted or escaped properly.
Bash is better but still terrible
POSIX shell script is nearly unusable for me
Subsentient
@Subsentient
Only pet peeves I have are A: The "or" thing which feels bizarre and likely to cause trouble, and B: the autocomplete is a bit unpredictable what it will do when you hit a given tab or -> key.
Aaron Gyes
@floam
the old behavior with bow it worked with begin, end could get tricky to wrap ones head around when you started chaining several conditionals together. It confused a lot of people, I'm afraid we won't be going back.
I'd take a look at maybe our circa fish 2.2.0 __fish_config_interactive, or some other heavy weight scripts, and ask yourself if you really find it all that elegant.
hm, bad example
anyhow.
Fabian Homborg
@faho

Damn, I really, really don't like that. Just a suggestion, but if it were me, I'd deprecate that usage of or in an if conditional with the semicolon preceding, and either A. Add documented syntax for 'or' used there without a semicolon, or B. move to || as the supported method. >.<

or without a semicolon is quite literally not possible and switching to just || won't happen.

And we are confident it does not cause trouble. We've had years of experience with it and it hasn't, not a single time. It's even how people expect it to work.
Emily Grace Seville
@EmilySeville7cfg
Where I can read source code for upcase-word function? VS Code file search produce no results.
Fabian Homborg
@faho
@EmilySeville7cfg It's not a function, it's implemented directly in the reader: https://github.com/fish-shell/fish-shell/blob/0cd3ed4b84e4cf02e560f0fd65a49c1633f915cb/src/reader.cpp#L3735-L3770
Emily Grace Seville
@EmilySeville7cfg
Thanks, it's time to learn C++ ;)
Aaron Gyes
@floam
nice, another little bug with the thompson shell script implementation:
Screen Shot 2021-12-02 at 3.23.26 AM.png
Fabian Homborg
@faho
@floam Ah, okay. We need to absolutize the path.
Aaron Gyes
@floam
yeah.
Fabian Homborg
@faho
(if it's coming via $PATH)
Aaron Gyes
@floam
you're faster than me. I was scratchng my head for a while.
Fabian Homborg
@faho
Yeah it's executing sh -, not sh /usr/local/bin/-.
Aaron Gyes
@floam
I didn't realize /bin/sh - would work.
Fabian Homborg
@faho
It's stdin, I guess?
Aaron Gyes
@floam
/usr/local/bin/--version would be a clearer demonstration.
I think it's like, the same as doing /bin/sh +, and it's just not turning anything on or off
Fabian Homborg
@faho
Ah, we pass the argv[0] value for the command we tried to execute as the command to sh.
Aaron Gyes
@floam
I wasted a couple minutes thinking it was somehow related to the parser or us changing argv for login mode or something goofy since command -technically needs a tiny adjustment to deal with that valid command name. But we just need to resolve that path.
When it needs to be actual_cmd.
Aaron Gyes
@floam
in postfork too
Fabian Homborg
@faho
Yup
Probably fixable by simply overwriting it after, no need to be clever.
Aaron Gyes
@floam
uh..
what in the world. https://github.com/zsh-users/zsh/blob/master/Src/exec.c#L552 That comment, whole spot is quite similar to the same in our own code.. 🤨
oh, same contributor. I guess zsh also had a bug. phew.
Aaron Gyes
@floam
huh
@faho I guess I thought it was just dragonbsd and solaris or something with no seq, but you're totally right, no seq, just jot, with its extra features but and sufficently complicated to translate command argument positions that you wouldn't want to bother.
this is a... quite brave commit: att/ast#860