git: 9792df1e16be - main - x11/kitty: Fix error with kitty+fish without sudo

From: Nicola Vitale <nivit_at_FreeBSD.org>
Date: Fri, 01 Dec 2023 14:35:05 UTC
The branch main has been updated by nivit:

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 +++-
 ...gration_fish_vendor__conf.d_kitty-shell-integration.fish | 13 +++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/x11/kitty/Makefile b/x11/kitty/Makefile
index 9369483e83c0..f13c8bd2147a 100644
--- a/x11/kitty/Makefile
+++ b/x11/kitty/Makefile
@@ -1,7 +1,7 @@
 PORTNAME=	kitty
 DISTVERSIONPREFIX=	v
 DISTVERSION=	0.31.0
-PORTREVISION=	0
+PORTREVISION=	1
 CATEGORIES=	x11 wayland
 
 MAINTAINER=	nivit@FreeBSD.org
@@ -103,6 +103,8 @@ EXTRA_PATCHES=	${PATCHDIR}/extra-patch-kitty_data-types.h
 
 post-patch:
 	${REINPLACE_CMD} -i.bak -e "s:'go':'${GO_CMD}':1" ${WRKSRC}/setup.py
+	${REINPLACE_CMD} -i.bak -e "s:%%DATADIR%%:${DATADIR}:1" \
+		${WRKSRC}/shell-integration/fish/vendor_conf.d/kitty-shell-integration.fish
 
 # For librsync, we need to set header and library path
 do-build:
diff --git a/x11/kitty/files/patch-shell-integration_fish_vendor__conf.d_kitty-shell-integration.fish b/x11/kitty/files/patch-shell-integration_fish_vendor__conf.d_kitty-shell-integration.fish
new file mode 100644
index 000000000000..3a6ccbc8db7a
--- /dev/null
+++ b/x11/kitty/files/patch-shell-integration_fish_vendor__conf.d_kitty-shell-integration.fish
@@ -0,0 +1,13 @@
+--- shell-integration/fish/vendor_conf.d/kitty-shell-integration.fish.orig	2023-12-01 13:31:58 UTC
++++ shell-integration/fish/vendor_conf.d/kitty-shell-integration.fish
+@@ -111,8 +111,8 @@ function __ksi_schedule --on-event fish_prompt -d "Set
+     # 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 not test -r "/usr/share/terminfo/x/xterm-kitty" -o -r "/usr/share/terminfo/78/xterm-kitty" 
++        and test -n "$TERMINFO" -a "file" = "(type -t sudo)"
++        and not test -r "%%DATADIR%%/terminfo/x/xterm-kitty" -o -r "/usr/share/terminfo/x/xterm-kitty" -o -r "/usr/share/terminfo/78/xterm-kitty" 
+         # Ensure terminfo is available in sudo
+         function sudo
+             set --local is_sudoedit "n"