fish-shell / fish-shell

The user-friendly command line shell.

Home Page:https://fishshell.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Flatpak completions include the author of the application preceded by a bunch of spaces

pixlxip opened this issue · comments

I am on fish version 3.7.1, the latest at the time of typing. I'm on Vanilla OS 2, running in an Ubuntu container. The terminal is Wezterm.

It's kind of hard to put into text other that actual text, so here's the asciinema:
https://asciinema.org/a/E2WgBX8kOPWagBAYWqozpiCYA

Basically, it inputs the app author and the spaces used to align the authors to the right of the screen, which it should not include. Sorry if this is confusing.

Can you show the flatpak version? Maybe flatpak --version?

flatpak ship a completion script upstream, maybe we should just remove the one with fish

https://github.com/flatpak/flatpak/blob/main/completion/flatpak.fish

Theirs doesn't provide descriptions for a lot of stuff. For some reason ours doesn't currently use flatpak remote-ls but it's very fast and a good candidate to use for completing flatpak install fo<TAB> , which upstream completions don't provide, either.


I think I found the issue, but it's weird. flatpak list --columns=application,name is detecting a tty when we are capturing the output in a "subshell".

What we expect, simulated by piping to cat:

> flatpak list --app --columns=application,name | cat
org.kde.okular  KDE

That's the id, a \t, then the name, which might contain spaces:

┌────────┬─────────────────────────┬─────────────────────────┬────────┬────────┐
│00000000│ 6f 72 67 2e 6b 64 65 2e ┊ 6f 6b 75 6c 61 72 09 4b │org.kde.┊okular_K│
│00000010│ 44 45 0a                ┊                         │DE_     ┊        │
└────────┴─────────────────────────┴─────────────────────────┴────────┴────────┘

What we get, which is the same as when flatpak thinks it is piping to a tty:

flatpak list --app --columns=application,name
Application ID      Name
org.kde.okular      KDE

which is pretty-formatted, includes the header row, and has multiple spaces (not one \t) for alignment:

> socat - EXEC:'flatpak list --app --columns=application\,name',pty,setsid,ctty | hexyl
┌────────┬─────────────────────────┬─────────────────────────┬────────┬────────┐
│00000000│ 1b 5b 31 6d 41 70 70 6c ┊ 69 63 61 74 69 6f 6e 20 │•[1mAppl┊ication │
│00000010│ 49 44 20 20 20 20 20 20 ┊ 4e 61 6d 65 1b 5b 32 32 │ID      ┊Name•[22│
│00000020│ 6d 0d 0a 6f 72 67 2e 6b ┊ 64 65 2e 6f 6b 75 6c 61 │m__org.k┊de.okula│
│00000030│ 72 20 20 20 20 20 20 4b ┊ 44 45 0d 0a             │r      K┊DE__    │
└────────┴─────────────────────────┴─────────────────────────┴────────┴────────┘

I can't reproduce this under master; did we have a fish bug where "subshell" executions would pass an isatty(3) check?


EDIT: I missed the obvious possibility, flatpak list checking isatty(3) is new behavior and OP is on an older version that never did that.

Upgrading to Flatpak 1.14.8 did not fix the problem.

For posterity, on my own machine running 1.14.4, I get sane isatty stdout output detection, so this isn't just a matter of old version vs new version.

@pixlxip while my focus here is/was one the completely broken formatting, it was pointed out to me on the flatpak matrix channel that the issue with the author instead of the name is due to a flatpak metadata corruption bug: flatpak/flatpak#5700