Fix false-positive check for tty in flatpak#39
Fix false-positive check for tty in flatpak#39MattSturgeon wants to merge 1 commit into0rax:masterfrom
Conversation
When there is absolutely no tty set at all (e.g. in a shell spawned by a flatpak), tty prints 'not a tty', which matches `tty | grep "tty"`. Luckily `tty` also returns `1`, so we can do a two-stage check instead. This fixes 0rax#38
0a0b187 to
f5813fc
Compare
|
Hello @MattSturgeon, thanks for your contribution. I can't really test everything right now and will take a look at it during the weekend. At a quick glance and by reading your comment, we might want to go with a regexp match here if it is more robust as this part of the code is only called during the initialization of fishline (one per shell process). I am also wondering if there might be a way to remove the special case for macOS ( The safe way might be to keep this special case for Darwin and just use your current regex suggestion as a sanity check. |
|
This stackexchange answer seems to indicate that on OS X the terminals will always be running in its own tty (e.g. On linux (at least openSUSE) We could match against not having a lowercase Perhaps we could somehow test if the system supports ptys before checking if we are on a tty? Maybe just Or perhaps there's some other way we can check if powerline symbols are available? I don't know if any reliable way to get the terminal's font... Some terminals set an environment variable to their name (IIRC EDIT: this discussion clarifies a few points. Seems macos uses a newer |
When there is absolutely no tty set at all (e.g. in a shell spawned by
a flatpak), tty prints
not a tty, which matches the current checktty | grep "tty".In normal shells it prints something like
/dev/pts/0, in actual ttys it prints something like/dev/tty1.Luckily
ttyalso returns1, so we can do a two-stage check instead:I figured it's better to use the faster substring matching rather than regex matching, especially if this is run every time a prompt is generated, but if not - or if you'd rather be more robust - let me know.
This fixes #38