Bug 275339 - [x11/kitty] prints error when starting fish within kitty
Summary: [x11/kitty] prints error when starting fish within kitty
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Nicola Vitale
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-11-25 21:39 UTC by keltir
Modified: 2023-12-01 14:43 UTC (History)
2 users (show)

See Also:
bugzilla: maintainer-feedback? (nivit)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description keltir 2023-11-25 21:39:54 UTC
It started after recent upgrade.
Version        : 3.6.1_1

Terminal is kitty - Version        : 0.31.0
Freebsd 14 release. installed from latest binary repo.

error:
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
type: Could not find 'sudo'
test: Expected a combining operator like '-a' at index 5
-n /usr/local/share/kitty/terminfo -a file =
                                           ^
Standard input (line 114): 
        and test -n "$TERMINFO" -a "file" = (type -t sudo)
            ^
in function '__ksi_schedule'
in event handler: handler for generic event 'fish_prompt'

I don't have sudo installed because I use doas in my system.


thnx in advance
Comment 1 Alan Somers freebsd_committer freebsd_triage 2023-11-25 23:29:15 UTC
The problem actually lies within kitty, not fish.  It's in the file /usr/local/share/kitty/shell-integration/fish/vendor_conf.d/kitty-shell-integration.fish at line 114.  It looks cosmetic to me; the error message is annoying but I don't think it will alter fish's behavior.  And I think this patch will fix it:

--- /usr/local/share/kitty/shell-integration/fish/vendor_conf.d/kitty-shell-integration.fish.orig	2023-11-25 16:27:56.135191000 -0700
+++ /usr/local/share/kitty/shell-integration/fish/vendor_conf.d/kitty-shell-integration.fish	2023-11-25 16:27:50.220297000 -0700
@@ -111,7 +111,7 @@
     # Note that neither alias nor function is recursive in fish so if the user defines an alias/function
     # for sudo it will be clobbered by us, so only install this if sudo is not already function
     if not contains "no-sudo" $_ksi
-        and test -n "$TERMINFO" -a "file" = (type -t sudo)
+        and test -n "$TERMINFO" -a "file" = "(type -t sudo)"
         and not test -r "/usr/share/terminfo/x/xterm-kitty" -o -r "/usr/share/terminfo/78/xterm-kitty" 
         # Ensure terminfo is available in sudo
         function sudo
Comment 2 commit-hook freebsd_committer freebsd_triage 2023-12-01 14:36:01 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=9792df1e16be41a313cc76824bbc3a8bb558d5f1

commit 9792df1e16be41a313cc76824bbc3a8bb558d5f1
Author:     Alan Somers <asomers@FreeBSD.org>
AuthorDate: 2023-12-01 14:30:06 +0000
Commit:     Nicola Vitale <nivit@FreeBSD.org>
CommitDate: 2023-12-01 14:34:10 +0000

    x11/kitty: Fix error with kitty+fish without sudo

    If a user has fish as shell and sudo is not installed, then kitty
    prints the following error:

    type: Could not find 'sudo'
    test: Expected a combining operator like '-a' at index 5
    -n /usr/local/share/kitty/terminfo -a file =
                                               ^
    Standard input (line 114):
            and test -n "$TERMINFO" -a "file" = (type -t sudo)
                ^
    in function '__ksi_schedule'
    in event handler: handler for generic event 'fish_prompt'

    - Add a patch to fix that error and to tests the presence of the
    xterm-kitty file in DATADIR

    - Bump PORTREVISION

    PR:     275339

 x11/kitty/Makefile                                          |  4 +++-
 ...n_fish_vendor__conf.d_kitty-shell-integration.fish (new) | 13 +++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)
Comment 3 Nicola Vitale freebsd_committer freebsd_triage 2023-12-01 14:43:37 UTC
Committed, thank you for the PR!