tcsh/tcsh-6.19.00-010-fix-editor-and-visual-variables-and-its-behaviour.patch
David Kaspar [Dee'Kej] 1cceba9f61 tcsh-6.19.00-010-fix-editor-and-visual-variables-and-its-behaviour.patch added
> Fix comparison of $EDITOR or $VISUAL against names of background
  > processes so that it doesn't just prefix match.

  > Rework run-fg-editor to use $editors exclusively if its set, and
  > ignore the use of $EDITOR (default "ed") and $VISUAL (default "vi").
2016-05-03 17:11:23 +02:00

291 lines
9.1 KiB
Diff

From acf067ec992e78e370f1101ba87d508774c32ed5 Mon Sep 17 00:00:00 2001
From: christos <christos>
Date: Fri, 31 Jul 2015 08:57:13 +0000
Subject: [PATCH 1/5] typo in comment (lukem)
---
sh.proc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sh.proc.c b/sh.proc.c
index aa2ee58..76eca3b 100644
--- a/sh.proc.c
+++ b/sh.proc.c
@@ -1003,7 +1003,7 @@ pprint(struct process *pp, int flag)
tp = pp;
status = reason = -1;
jobflags = 0;
- haderr = 1; /* Print statuc to stderr */
+ haderr = 1; /* Print status to stderr */
do {
#ifdef BACKPIPE
/*
--
2.5.5
From e8eb0eba59a96e90e2a63952aaf7092b5e5569d2 Mon Sep 17 00:00:00 2001
From: christos <christos>
Date: Fri, 31 Jul 2015 08:58:37 +0000
Subject: [PATCH 2/5] From lukem: run-fg-editor: don't prefix match $EDITOR,
$VISUAL
Fix comparison of $EDITOR or $VISUAL against names of background
processes so that it doesn't just prefix match.
Previously, if EDITOR=vi it would match any command starting with "vi".
Move check for backgrounded jobs earlier to avoid unnecessary work.
---
tc.func.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/tc.func.c b/tc.func.c
index 5a909d6..7ed32cf 100644
--- a/tc.func.c
+++ b/tc.func.c
@@ -520,6 +520,9 @@ find_stop_ed(void)
struct varent *varp;
Char **vv;
+ if (pcurrent == NULL) /* see if we have any jobs */
+ return NULL; /* nope */
+
if ((ep = getenv("EDITOR")) != NULL) { /* if we have a value */
if ((p = strrchr(ep, '/')) != NULL) /* if it has a path */
ep = p + 1; /* then we want only the last part */
@@ -539,9 +542,6 @@ find_stop_ed(void)
for (epl = 0; ep[epl] && !isspace((unsigned char)ep[epl]); epl++)
continue;
- if (pcurrent == NULL) /* see if we have any jobs */
- return NULL; /* nope */
-
if ((varp = adrof(STReditors)) != NULL)
vv = varp->vec;
else
@@ -572,9 +572,13 @@ find_stop_ed(void)
else
cp = p; /* else we get all of it */
- /* if we find either in the current name, fg it */
- if (strncmp(ep, cp, epl) == 0 ||
- strncmp(vp, cp, vpl) == 0 || findvv(vv, cp)) {
+ /*
+ * If we find the current name as $EDITOR or $VISUAL,
+ * or in $editors array, fg it
+ */
+ if ((strncmp(ep, cp, epl) == 0 && cp[epl] == '\0') ||
+ (strncmp(vp, cp, vpl) == 0 && cp[vpl] == '\0') ||
+ findvv(vv, cp)) {
/*
* If there is a choice, then choose the current process if
--
2.5.5
From 39822a2b0d29d2314da10c7a94f7ad0cdaf80509 Mon Sep 17 00:00:00 2001
From: christos <christos>
Date: Fri, 31 Jul 2015 08:59:53 +0000
Subject: [PATCH 3/5] Rework run-fg-editor to use $editors exclusively if its
set, and ignore the use of $EDITOR (default "ed") and $VISUAL (default "vi").
If $editors is not set, fallback to the previous use of $EDITOR and $VISUAL.
(from lukem)
---
tc.func.c | 55 ++++++++++++++++++++++++++++---------------------------
1 file changed, 28 insertions(+), 27 deletions(-)
diff --git a/tc.func.c b/tc.func.c
index 7ed32cf..9af4858 100644
--- a/tc.func.c
+++ b/tc.func.c
@@ -513,9 +513,9 @@ struct process *
find_stop_ed(void)
{
struct process *pp, *retp;
- const char *ep, *vp;
+ const char *ep = NULL, *vp = NULL;
char *cp, *p;
- size_t epl, vpl;
+ size_t epl = 0, vpl = 0;
int pstatus;
struct varent *varp;
Char **vv;
@@ -523,30 +523,32 @@ find_stop_ed(void)
if (pcurrent == NULL) /* see if we have any jobs */
return NULL; /* nope */
- if ((ep = getenv("EDITOR")) != NULL) { /* if we have a value */
- if ((p = strrchr(ep, '/')) != NULL) /* if it has a path */
- ep = p + 1; /* then we want only the last part */
- }
- else
- ep = "ed";
-
- if ((vp = getenv("VISUAL")) != NULL) { /* if we have a value */
- if ((p = strrchr(vp, '/')) != NULL) /* and it has a path */
- vp = p + 1; /* then we want only the last part */
- }
- else
- vp = "vi";
-
- for (vpl = 0; vp[vpl] && !isspace((unsigned char)vp[vpl]); vpl++)
- continue;
- for (epl = 0; ep[epl] && !isspace((unsigned char)ep[epl]); epl++)
- continue;
-
if ((varp = adrof(STReditors)) != NULL)
vv = varp->vec;
else
vv = NULL;
+ if (! vv) {
+ if ((ep = getenv("EDITOR")) != NULL) { /* if we have a value */
+ if ((p = strrchr(ep, '/')) != NULL) /* if it has a path */
+ ep = p + 1; /* then we want only the last part */
+ }
+ else
+ ep = "ed";
+
+ if ((vp = getenv("VISUAL")) != NULL) { /* if we have a value */
+ if ((p = strrchr(vp, '/')) != NULL) /* and it has a path */
+ vp = p + 1; /* then we want only the last part */
+ }
+ else
+ vp = "vi";
+
+ for (vpl = 0; vp[vpl] && !isspace((unsigned char)vp[vpl]); vpl++)
+ continue;
+ for (epl = 0; ep[epl] && !isspace((unsigned char)ep[epl]); epl++)
+ continue;
+ }
+
retp = NULL;
for (pp = proclist.p_next; pp; pp = pp->p_next)
if (pp->p_procid == pp->p_jobid) {
@@ -573,13 +575,12 @@ find_stop_ed(void)
cp = p; /* else we get all of it */
/*
- * If we find the current name as $EDITOR or $VISUAL,
- * or in $editors array, fg it
+ * If we find the current name in the $editors array (if set)
+ * or as $EDITOR or $VISUAL (if $editors not set), fg it.
*/
- if ((strncmp(ep, cp, epl) == 0 && cp[epl] == '\0') ||
- (strncmp(vp, cp, vpl) == 0 && cp[vpl] == '\0') ||
- findvv(vv, cp)) {
-
+ if ((vv && findvv(vv, cp)) ||
+ (epl && strncmp(ep, cp, epl) == 0 && cp[epl] == '\0') ||
+ (vpl && strncmp(vp, cp, vpl) == 0 && cp[vpl] == '\0')) {
/*
* If there is a choice, then choose the current process if
* available, or the previous process otherwise, or else
--
2.5.5
From 6ca81f5b7730071db2a414167d3782ce955fb76b Mon Sep 17 00:00:00 2001
From: christos <christos>
Date: Fri, 31 Jul 2015 09:00:14 +0000
Subject: [PATCH 4/5] Document the $editors support and this new behaviour. (It
was originally added in tcsh 6.18.03 without notice). (from lukem)
---
tcsh.man | 27 +++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)
diff --git a/tcsh.man b/tcsh.man
index 4fa59d2..1ad5529 100644
--- a/tcsh.man
+++ b/tcsh.man
@@ -77,7 +77,7 @@
.\" used here if you can. In particular, please don't use nroff commands
.\" which aren't already used herein.
.\"
-.TH TCSH 1 "21 May 2015" "Astron 6.19.00"
+.TH TCSH 1 "31 July 2015" "Astron 6.19.00"
.SH NAME
tcsh \- C shell with file name completion and command line editing
.SH SYNOPSIS
@@ -723,9 +723,13 @@ Toggles between input and overwrite modes.
.TP 8
.B run-fg-editor \fR(M-^Z)
Saves the current input line and
-looks for a stopped job with a name equal to the last component of the
-file name part of the \fBEDITOR\fR or \fBVISUAL\fR environment variables,
-or, if neither is set, `ed' or `vi'.
+looks for a stopped job where the file name portion of its first word
+is found in the \fBeditors\fR shell variable.
+If \fBeditors\fR is not set, then the file name portion of the
+\fBEDITOR\fR environment variable (`ed' if unset)
+and the
+\fBVISUAL\fR environment variable (`vi' if unset)
+will be used.
If such a job is found, it is restarted as if `fg %\fIjob\fR' had been
typed. This is used to toggle back and forth between an editor and
the shell easily. Some people bind this command to `^Z' so they
@@ -3884,6 +3888,11 @@ systems.
If set, the command-line editor is used. Set by default in interactive
shells.
.TP 8
+.B editors \fR(+)
+A list of command names for the \fIrun-fg-editor\fR editor command to match.
+If not set, the \fBEDITOR\fR (`ed' if unset) and \fBVISUAL\fR (`vi' if unset)
+environment variables will be used instead.
+.TP 8
.B ellipsis \fR(+)
If set, the `%c'/`%.' and `%C' prompt sequences (see the \fBprompt\fR
shell variable) indicate skipped directories with an ellipsis (`...')
@@ -4783,8 +4792,9 @@ If set, the shell does not set \fBautologout\fR (q.v.).
.TP 8
.B EDITOR
The pathname to a default editor.
-See also the \fBVISUAL\fR environment variable
-and the \fIrun-fg-editor\fR editor command.
+Used by the \fIrun-fg-editor\fR editor command if the
+the \fBeditors\fR shell variable is unset.
+See also the \fBVISUAL\fR environment variable.
.TP 8
.B GROUP \fR(+)
Equivalent to the \fBgroup\fR shell variable.
@@ -5020,8 +5030,9 @@ The vendor, as determined at compile time.
.TP 8
.B VISUAL
The pathname to a default full-screen editor.
-See also the \fBEDITOR\fR environment variable
-and the \fIrun-fg-editor\fR editor command.
+Used by the \fIrun-fg-editor\fR editor command if the
+the \fBeditors\fR shell variable is unset.
+See also the \fBEDITOR\fR environment variable.
.SH FILES
.PD 0
.TP 16
--
2.5.5
From a16fbf87a3459c7305755aa301d7e04fa806d2ec Mon Sep 17 00:00:00 2001
From: christos <christos>
Date: Fri, 31 Jul 2015 09:01:17 +0000
Subject: [PATCH 5/5] mention run-fg-editor fixes
---
Fixes | 1 +
1 file changed, 1 insertion(+)
diff --git a/Fixes b/Fixes
index 07afe71..e58d879 100644
--- a/Fixes
+++ b/Fixes
@@ -1,3 +1,4 @@
+ 4. run-fg-editor improvements and documentation (Luke Mewburn)
3. Fix parsing of 'if (cond)then' (Fridolin Pokorny)
2. PR/437: Fix handling of invalid unicode characters.
1. PR/451: Fix error messages containing %c to be always '%c'
--
2.5.5