git: 6c11c9f48a51 - main - net/quagga: use MORE=-E implicitly within vtysh

From: Eugene Grosbein <eugen_at_FreeBSD.org>
Date: Sat, 31 Dec 2022 17:17:14 UTC
The branch main has been updated by eugen:

URL: https://cgit.FreeBSD.org/ports/commit/?id=6c11c9f48a511b4097e532fd678726b5d3e17e8b

commit 6c11c9f48a511b4097e532fd678726b5d3e17e8b
Author:     Eugene Grosbein <eugen@FreeBSD.org>
AuthorDate: 2022-12-31 17:09:38 +0000
Commit:     Eugene Grosbein <eugen@FreeBSD.org>
CommitDate: 2022-12-31 17:17:05 +0000

    net/quagga: use MORE=-E implicitly within vtysh
    
    quagga's vtysh utility defaults to "more" as PAGER that is less(1)
    under FreeBSD and its current behaviour is not suitable for vtysh.
    
    Generally, setting MORE=-E in user environment makes it behave better
    but due to collateral damage in bash version 5+
    this setting may be ignored.
    
    Let's make it work out of the box while still allowing users to change or
    restore pager behaviour with custom MORE settings.
---
 net/quagga/Makefile            |  2 +-
 net/quagga/files/patch-vtysh.c | 29 +++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/net/quagga/Makefile b/net/quagga/Makefile
index b9ac0900006e..edce72330110 100644
--- a/net/quagga/Makefile
+++ b/net/quagga/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	quagga
 PORTVERSION=	1.2.4
-PORTREVISION=	9
+PORTREVISION=	10
 CATEGORIES=	net
 MASTER_SITES=	https://github.com/Quagga/quagga/releases/download/${DISTNAME}/
 
diff --git a/net/quagga/files/patch-vtysh.c b/net/quagga/files/patch-vtysh.c
new file mode 100644
index 000000000000..e5779a1de11d
--- /dev/null
+++ b/net/quagga/files/patch-vtysh.c
@@ -0,0 +1,29 @@
+--- vtysh/vtysh.c.orig	2018-02-20 00:24:55.000000000 +0300
++++ vtysh/vtysh.c	2022-12-31 19:56:32.203501000 +0300
+@@ -246,7 +246,7 @@ vtysh_client_execute (struct vtysh_client *vclient, co
+ void
+ vtysh_pager_init (void)
+ {
+-  char *pager_defined;
++  char *pager_defined, *s;
+ 
+   pager_defined = getenv ("VTYSH_PAGER");
+ 
+@@ -254,6 +254,17 @@ vtysh_pager_init (void)
+     vtysh_pager_name = strdup (pager_defined);
+   else
+     vtysh_pager_name = strdup ("more");
++
++  s = getenv("MORE");
++  if (s != NULL)
++    return;
++
++  s = strrchr(vtysh_pager_name, '/');
++  s = (s == NULL ? vtysh_pager_name : s++);
++  if (strcmp(s, "more") != 0 && strcmp(s, "less") != 0)
++    return;
++
++  putenv("MORE=-E");
+ }
+ 
+ /* Command execution over the vty interface. */