zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] make TERMINFO_DIRS variable special
@ 2016-11-08 20:26 ` Guillaume Maudoux
  2016-11-09 14:47   ` Guillaume Maudoux (Layus)
  0 siblings, 1 reply; 6+ messages in thread
From: Guillaume Maudoux @ 2016-11-08 20:26 UTC (permalink / raw)
  To: zsh-workers; +Cc: Guillaume Maudoux

---
 Doc/Zsh/params.yo | 15 +++++++++++----
 Src/params.c      | 31 +++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 4 deletions(-)

diff --git a/Doc/Zsh/params.yo b/Doc/Zsh/params.yo
index c7d84b9..728fc21 100644
--- a/Doc/Zsh/params.yo
+++ b/Doc/Zsh/params.yo
@@ -1485,10 +1485,17 @@ take effect.
 )
 vindex(TERMINFO)
 item(tt(TERMINFO) <S>)(
-A reference to a compiled description of the terminal, used by the
-`terminfo' library when the system has it; see manref(terminfo)(5).
-If set, this causes the shell to reinitialise the terminal, making
-the workaround `tt(TERM=$TERM)' unnecessary.
+A reference to a directory containing the compiled description of
+terminals, used by the `terminfo' library when the system has it; see
+manref(terminfo)(5).  If set, this causes the shell to reinitialise the
+terminal, making the workaround `tt(TERM=$TERM)' unnecessary.
+)
+vindex(TERMINFO_DIRS)
+item(tt(TERMINFO_DIRS) <S>)(
+An array (colon-separated list) of paths to be searched for a compiled
+description of the terminal, used by the `terminfo' library when the system has
+it; see manref(terminfo)(5).  If set, this causes the shell to reinitialise the
+terminal, making the workaround `tt(TERM=$TERM)' unnecessary.
 )
 vindex(TIMEFMT)
 item(tt(TIMEFMT))(
diff --git a/Src/params.c b/Src/params.c
index 19a8c29..92b8ac1 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -87,6 +87,7 @@ char *ifs,		/* $IFS         */
      *postedit,		/* $POSTEDIT    */
      *term,		/* $TERM        */
      *zsh_terminfo,     /* $TERMINFO    */
+     *zsh_terminfodirs, /* $TERMINFO_DIRS */
      *ttystrname,	/* $TTY         */
      *pwd;		/* $PWD         */
 
@@ -208,6 +209,8 @@ static const struct gsu_scalar term_gsu =
 { termgetfn, termsetfn, stdunsetfn };
 static const struct gsu_scalar terminfo_gsu =
 { terminfogetfn, terminfosetfn, stdunsetfn };
+static const struct gsu_scalar terminfodirs_gsu =
+{ terminfodirsgetfn, terminfodirssetfn, stdunsetfn };
 static const struct gsu_scalar wordchars_gsu =
 { wordcharsgetfn, wordcharssetfn, stdunsetfn };
 static const struct gsu_scalar ifs_gsu =
@@ -283,6 +286,7 @@ IPDEF2("histchars", histchars_gsu, PM_DONTIMPORT),
 IPDEF2("HOME", home_gsu, PM_UNSET),
 IPDEF2("TERM", term_gsu, PM_UNSET),
 IPDEF2("TERMINFO", terminfo_gsu, PM_UNSET),
+IPDEF2("TERMINFO_DIRS", terminfodirs_gsu, PM_UNSET),
 IPDEF2("WORDCHARS", wordchars_gsu, 0),
 IPDEF2("IFS", ifs_gsu, PM_DONTIMPORT | PM_RESTRICTED),
 IPDEF2("_", underscore_gsu, PM_DONTIMPORT),
@@ -4511,6 +4515,33 @@ terminfosetfn(Param pm, char *x)
     term_reinit_from_pm();
 }
 
+/* Function to get value of special parameter `TERMINFO_DIRS' */
+
+/**/
+char *
+terminfodirsgetfn(UNUSED(Param pm))
+{
+    return zsh_terminfodirs ? zsh_terminfodirs : dupstring("");
+}
+
+/* Function to set value of special parameter `TERMINFO_DIRS' */
+
+/**/
+void
+terminfodirssetfn(Param pm, char *x)
+{
+    zsfree(zsh_terminfodirs);
+    zsh_terminfodirs = x;
+
+    /*
+     * terminfo relies on the value being exported before
+     * we reinitialise the terminal.  This is a bit inefficient.
+     */
+    if ((pm->node.flags & PM_EXPORTED) && x)
+	addenv(pm, x);
+
+    term_reinit_from_pm();
+}
 /* Function to get value for special parameter `pipestatus' */
 
 /**/
-- 
2.10.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] make TERMINFO_DIRS variable special
  2016-11-08 20:26 ` [PATCH] make TERMINFO_DIRS variable special Guillaume Maudoux
@ 2016-11-09 14:47   ` Guillaume Maudoux (Layus)
  2016-11-09 15:26     ` Peter Stephenson
  0 siblings, 1 reply; 6+ messages in thread
From: Guillaume Maudoux (Layus) @ 2016-11-09 14:47 UTC (permalink / raw)
  To: zsh-workers

I realize that this patch needs some introduction.

First, it is the logical follow-up of commit
c59e19cd774a9c5fb658a4b538ab505d608820a5
Author: Peter Stephenson <pws@users.sourceforge.net>
Date:   Tue May 10 15:40:32 2011 +0000

    29191 (Danek) and 29203 (with fixes): make TERMINFO variable special.

Second, there has been discussion on the mailing list about his before.
The general idea is that terminfo look for these varibales via getenv(),
To pass them correctly, we need to export them to our own environment.
The term update is just a nice extra feature avoiding the TERM=$TERM trick.
See discussion about this in [1]

Third, there has already been an update for this issue in fish[2].
Bash seems unaffected by this issue, but I have no idea why...

Finally, this arises from an issue in the nixpkgs tracker, at [3].

I am not aware of the review/accept policy for patches.
Could you tell me if this one has any chance to get merged ?

Regards

Guillaume Maudoux, aka layus.

[1] http://www.zsh.org/mla/workers/2011/threads.html#00626
[2]
https://github.com/fish-shell/fish-shell/commit/53e865b65434fa9ec12afc11a076aec244cd3c43#diff-4f6a3b01f66a27bdc0739167d1aed5a5
[3] https://github.com/NixOS/nixpkgs/issues/19785



Le 08/11/16 à 21:26, Guillaume Maudoux a écrit :
> ---
>  Doc/Zsh/params.yo | 15 +++++++++++----
>  Src/params.c      | 31 +++++++++++++++++++++++++++++++
>  2 files changed, 42 insertions(+), 4 deletions(-)
>
> diff --git a/Doc/Zsh/params.yo b/Doc/Zsh/params.yo
> index c7d84b9..728fc21 100644
> --- a/Doc/Zsh/params.yo
> +++ b/Doc/Zsh/params.yo
> @@ -1485,10 +1485,17 @@ take effect.
>  )
>  vindex(TERMINFO)
>  item(tt(TERMINFO) <S>)(
> -A reference to a compiled description of the terminal, used by the
> -`terminfo' library when the system has it; see manref(terminfo)(5).
> -If set, this causes the shell to reinitialise the terminal, making
> -the workaround `tt(TERM=$TERM)' unnecessary.
> +A reference to a directory containing the compiled description of
> +terminals, used by the `terminfo' library when the system has it; see
> +manref(terminfo)(5).  If set, this causes the shell to reinitialise the
> +terminal, making the workaround `tt(TERM=$TERM)' unnecessary.
> +)
> +vindex(TERMINFO_DIRS)
> +item(tt(TERMINFO_DIRS) <S>)(
> +An array (colon-separated list) of paths to be searched for a compiled
> +description of the terminal, used by the `terminfo' library when the system has
> +it; see manref(terminfo)(5).  If set, this causes the shell to reinitialise the
> +terminal, making the workaround `tt(TERM=$TERM)' unnecessary.
>  )
>  vindex(TIMEFMT)
>  item(tt(TIMEFMT))(
> diff --git a/Src/params.c b/Src/params.c
> index 19a8c29..92b8ac1 100644
> --- a/Src/params.c
> +++ b/Src/params.c
> @@ -87,6 +87,7 @@ char *ifs,		/* $IFS         */
>       *postedit,		/* $POSTEDIT    */
>       *term,		/* $TERM        */
>       *zsh_terminfo,     /* $TERMINFO    */
> +     *zsh_terminfodirs, /* $TERMINFO_DIRS */
>       *ttystrname,	/* $TTY         */
>       *pwd;		/* $PWD         */
>  
> @@ -208,6 +209,8 @@ static const struct gsu_scalar term_gsu =
>  { termgetfn, termsetfn, stdunsetfn };
>  static const struct gsu_scalar terminfo_gsu =
>  { terminfogetfn, terminfosetfn, stdunsetfn };
> +static const struct gsu_scalar terminfodirs_gsu =
> +{ terminfodirsgetfn, terminfodirssetfn, stdunsetfn };
>  static const struct gsu_scalar wordchars_gsu =
>  { wordcharsgetfn, wordcharssetfn, stdunsetfn };
>  static const struct gsu_scalar ifs_gsu =
> @@ -283,6 +286,7 @@ IPDEF2("histchars", histchars_gsu, PM_DONTIMPORT),
>  IPDEF2("HOME", home_gsu, PM_UNSET),
>  IPDEF2("TERM", term_gsu, PM_UNSET),
>  IPDEF2("TERMINFO", terminfo_gsu, PM_UNSET),
> +IPDEF2("TERMINFO_DIRS", terminfodirs_gsu, PM_UNSET),
>  IPDEF2("WORDCHARS", wordchars_gsu, 0),
>  IPDEF2("IFS", ifs_gsu, PM_DONTIMPORT | PM_RESTRICTED),
>  IPDEF2("_", underscore_gsu, PM_DONTIMPORT),
> @@ -4511,6 +4515,33 @@ terminfosetfn(Param pm, char *x)
>      term_reinit_from_pm();
>  }
>  
> +/* Function to get value of special parameter `TERMINFO_DIRS' */
> +
> +/**/
> +char *
> +terminfodirsgetfn(UNUSED(Param pm))
> +{
> +    return zsh_terminfodirs ? zsh_terminfodirs : dupstring("");
> +}
> +
> +/* Function to set value of special parameter `TERMINFO_DIRS' */
> +
> +/**/
> +void
> +terminfodirssetfn(Param pm, char *x)
> +{
> +    zsfree(zsh_terminfodirs);
> +    zsh_terminfodirs = x;
> +
> +    /*
> +     * terminfo relies on the value being exported before
> +     * we reinitialise the terminal.  This is a bit inefficient.
> +     */
> +    if ((pm->node.flags & PM_EXPORTED) && x)
> +	addenv(pm, x);
> +
> +    term_reinit_from_pm();
> +}
>  /* Function to get value for special parameter `pipestatus' */
>  
>  /**/


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] make TERMINFO_DIRS variable special
  2016-11-09 14:47   ` Guillaume Maudoux (Layus)
@ 2016-11-09 15:26     ` Peter Stephenson
  2016-11-09 15:35       ` Guillaume Maudoux (Layus)
  0 siblings, 1 reply; 6+ messages in thread
From: Peter Stephenson @ 2016-11-09 15:26 UTC (permalink / raw)
  To: zsh-workers; +Cc: Guillaume Maudoux (Layus)

On Wed, 9 Nov 2016 15:47:10 +0100
"Guillaume Maudoux (Layus)" <layus.on@gmail.com> wrote:
> The general idea is that terminfo look for these varibales via getenv(),
> To pass them correctly, we need to export them to our own environment.
> The term update is just a nice extra feature avoiding the TERM=$TERM trick.
>
> I am not aware of the review/accept policy for patches.
> Could you tell me if this one has any chance to get merged ?

Can't see any problem generally, given it's exactly parellel to the
TERMINFO trick.

Usually you just need to post it (without the "> " and by any mechanism
that doesn't cause line wrap or other modifications) and wait for people
to comment.

One issue is that the doc implies (and people would probably expect)
that TERMINFO_DIRS is a tied variable with a terminfo_dirs array
equivalent. This doesn't exist.  This would need accessors along the
lines of the contents of colonarr_gsu for the colon-separated version
and vararray_gsu for the array version.  Possibly only the setters are
different.

pws


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] make TERMINFO_DIRS variable special
  2016-11-09 15:26     ` Peter Stephenson
@ 2016-11-09 15:35       ` Guillaume Maudoux (Layus)
  2016-11-09 16:14         ` Guillaume Maudoux
  0 siblings, 1 reply; 6+ messages in thread
From: Guillaume Maudoux (Layus) @ 2016-11-09 15:35 UTC (permalink / raw)
  To: Peter Stephenson, zsh-workers



Le 09/11/16 à 16:26, Peter Stephenson a écrit :
> On Wed, 9 Nov 2016 15:47:10 +0100
> "Guillaume Maudoux (Layus)" <layus.on@gmail.com> wrote:
>> The general idea is that terminfo look for these varibales via getenv(),
>> To pass them correctly, we need to export them to our own environment.
>> The term update is just a nice extra feature avoiding the TERM=$TERM trick.
>>
>> I am not aware of the review/accept policy for patches.
>> Could you tell me if this one has any chance to get merged ?
> Can't see any problem generally, given it's exactly parellel to the
> TERMINFO trick.
>
> Usually you just need to post it (without the "> " and by any mechanism
> that doesn't cause line wrap or other modifications) and wait for people
> to comment.
My initial mail contained only the patch, in the correct format.
I then send a description, scrambling the patch... Seems like I am
unable to get both right ;-).
> One issue is that the doc implies (and people would probably expect)
> that TERMINFO_DIRS is a tied variable with a terminfo_dirs array
> equivalent. This doesn't exist.  This would need accessors along the
> lines of the contents of colonarr_gsu for the colon-separated version
> and vararray_gsu for the array version.  Possibly only the setters are
> different.
Would it be okay to change only the docs ? There is no reason to make
TERMINFO_DIRS a tied variable.
It's a basic raw variable passed to ncurses, not a widely used variable
like $path.
I just copied the description of some array variable, trying to be smart...

I will submit the same patch with a better doc.
>
> pws
layus


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] make TERMINFO_DIRS variable special
  2016-11-09 15:35       ` Guillaume Maudoux (Layus)
@ 2016-11-09 16:14         ` Guillaume Maudoux
  2016-11-09 16:14           ` Guillaume Maudoux
  0 siblings, 1 reply; 6+ messages in thread
From: Guillaume Maudoux @ 2016-11-09 16:14 UTC (permalink / raw)
  To: zsh-workers

Here comes the updated patch.

-- layus.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] make TERMINFO_DIRS variable special
  2016-11-09 16:14         ` Guillaume Maudoux
@ 2016-11-09 16:14           ` Guillaume Maudoux
  0 siblings, 0 replies; 6+ messages in thread
From: Guillaume Maudoux @ 2016-11-09 16:14 UTC (permalink / raw)
  To: zsh-workers; +Cc: Guillaume Maudoux

---
 Doc/Zsh/params.yo | 16 ++++++++++++----
 Src/params.c      | 31 +++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+), 4 deletions(-)

diff --git a/Doc/Zsh/params.yo b/Doc/Zsh/params.yo
index c7d84b9..d9f7103 100644
--- a/Doc/Zsh/params.yo
+++ b/Doc/Zsh/params.yo
@@ -1485,10 +1485,18 @@ take effect.
 )
 vindex(TERMINFO)
 item(tt(TERMINFO) <S>)(
-A reference to a compiled description of the terminal, used by the
-`terminfo' library when the system has it; see manref(terminfo)(5).
-If set, this causes the shell to reinitialise the terminal, making
-the workaround `tt(TERM=$TERM)' unnecessary.
+A reference to your terminfo database, used by the `terminfo' library when the
+system has it; see manref(terminfo)(5).
+If set, this causes the shell to reinitialise the terminal, making the
+workaround `tt(TERM=$TERM)' unnecessary.
+)
+vindex(TERMINFO_DIRS)
+item(tt(TERMINFO_DIRS) <S>)(
+A colon-seprarated list of terminfo databases, used by the `terminfo' library
+when the system has it; see manref(terminfo)(5). This variable seems specific
+to ncurses. Again, see manref(terminfo)(5) to check support on your system.
+If set, this causes the shell to reinitialise the terminal, making the
+workaround `tt(TERM=$TERM)' unnecessary.
 )
 vindex(TIMEFMT)
 item(tt(TIMEFMT))(
diff --git a/Src/params.c b/Src/params.c
index 19a8c29..92b8ac1 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -87,6 +87,7 @@ char *ifs,		/* $IFS         */
      *postedit,		/* $POSTEDIT    */
      *term,		/* $TERM        */
      *zsh_terminfo,     /* $TERMINFO    */
+     *zsh_terminfodirs, /* $TERMINFO_DIRS */
      *ttystrname,	/* $TTY         */
      *pwd;		/* $PWD         */
 
@@ -208,6 +209,8 @@ static const struct gsu_scalar term_gsu =
 { termgetfn, termsetfn, stdunsetfn };
 static const struct gsu_scalar terminfo_gsu =
 { terminfogetfn, terminfosetfn, stdunsetfn };
+static const struct gsu_scalar terminfodirs_gsu =
+{ terminfodirsgetfn, terminfodirssetfn, stdunsetfn };
 static const struct gsu_scalar wordchars_gsu =
 { wordcharsgetfn, wordcharssetfn, stdunsetfn };
 static const struct gsu_scalar ifs_gsu =
@@ -283,6 +286,7 @@ IPDEF2("histchars", histchars_gsu, PM_DONTIMPORT),
 IPDEF2("HOME", home_gsu, PM_UNSET),
 IPDEF2("TERM", term_gsu, PM_UNSET),
 IPDEF2("TERMINFO", terminfo_gsu, PM_UNSET),
+IPDEF2("TERMINFO_DIRS", terminfodirs_gsu, PM_UNSET),
 IPDEF2("WORDCHARS", wordchars_gsu, 0),
 IPDEF2("IFS", ifs_gsu, PM_DONTIMPORT | PM_RESTRICTED),
 IPDEF2("_", underscore_gsu, PM_DONTIMPORT),
@@ -4511,6 +4515,33 @@ terminfosetfn(Param pm, char *x)
     term_reinit_from_pm();
 }
 
+/* Function to get value of special parameter `TERMINFO_DIRS' */
+
+/**/
+char *
+terminfodirsgetfn(UNUSED(Param pm))
+{
+    return zsh_terminfodirs ? zsh_terminfodirs : dupstring("");
+}
+
+/* Function to set value of special parameter `TERMINFO_DIRS' */
+
+/**/
+void
+terminfodirssetfn(Param pm, char *x)
+{
+    zsfree(zsh_terminfodirs);
+    zsh_terminfodirs = x;
+
+    /*
+     * terminfo relies on the value being exported before
+     * we reinitialise the terminal.  This is a bit inefficient.
+     */
+    if ((pm->node.flags & PM_EXPORTED) && x)
+	addenv(pm, x);
+
+    term_reinit_from_pm();
+}
 /* Function to get value for special parameter `pipestatus' */
 
 /**/
-- 
2.10.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-11-10  9:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <12935.1478707087@hydra.kiddle.eu>
2016-11-08 20:26 ` [PATCH] make TERMINFO_DIRS variable special Guillaume Maudoux
2016-11-09 14:47   ` Guillaume Maudoux (Layus)
2016-11-09 15:26     ` Peter Stephenson
2016-11-09 15:35       ` Guillaume Maudoux (Layus)
2016-11-09 16:14         ` Guillaume Maudoux
2016-11-09 16:14           ` Guillaume Maudoux

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).