tcsh: support both $anyerror and $tcsh_posix_status
Before, the $tcsh_posix_status was added but the $anyerror support was removed, but we need to have both. Resolves: #1129703 Version: 6.18.01-12
This commit is contained in:
parent
e6c2d010fe
commit
804e62644c
145
tcsh-6.18.01-introduce-tcsh_posix_status.patch
Normal file
145
tcsh-6.18.01-introduce-tcsh_posix_status.patch
Normal file
@ -0,0 +1,145 @@
|
||||
From 5f012d155159b96f2a458ba047085cb1b348befc Mon Sep 17 00:00:00 2001
|
||||
From: Pavel Raiskup <praiskup@redhat.com>
|
||||
Date: Mon, 28 Jul 2014 14:47:33 +0200
|
||||
Subject: [PATCH 13/15] downstream: implement variable tcsh_posix_status
|
||||
|
||||
This patch partially reverts the dist-git commit e0b2d458fda4
|
||||
because we _don't_ really want drop upstream-supported 'anyerror'
|
||||
variable. And we can not drop tcsh_posix_status neither, as we
|
||||
already support that in RHEL5+ downstream.
|
||||
|
||||
So from now, if "!defined(anyerror) ||
|
||||
defined(tcsh_posix_status)", tcsh behaves, with regards to
|
||||
pipelines, same way as POSIX-like shells.
|
||||
|
||||
Note: This feature is left undocumented intentionaly, just to push people use
|
||||
the upstream supported $anyerror.
|
||||
|
||||
Resolves: #1129703
|
||||
Related: #759132
|
||||
|
||||
---
|
||||
sh.c | 2 ++
|
||||
sh.h | 1 +
|
||||
sh.proc.c | 2 +-
|
||||
sh.set.c | 5 +++++
|
||||
tc.const.c | 2 ++
|
||||
tests/variables.at | 28 ++++++++++++++++++++++++++++
|
||||
6 files changed, 39 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/sh.c b/sh.c
|
||||
index f897317..498bf25 100644
|
||||
--- a/sh.c
|
||||
+++ b/sh.c
|
||||
@@ -354,6 +354,8 @@ main(int argc, char **argv)
|
||||
anyerror = 1; /* for compatibility */
|
||||
setcopy(STRanyerror, STRNULL, VAR_READWRITE);
|
||||
|
||||
+ tcsh_posix_status = 0;
|
||||
+
|
||||
/* Default history size to 100 */
|
||||
setcopy(STRhistory, str2short("100"), VAR_READWRITE);
|
||||
|
||||
diff --git a/sh.h b/sh.h
|
||||
index 4e3f13c..74b7719 100644
|
||||
--- a/sh.h
|
||||
+++ b/sh.h
|
||||
@@ -597,6 +597,7 @@ EXTERN int editing IZERO; /* doing filename expansion and line editing */
|
||||
EXTERN int noediting IZERO; /* initial $term defaulted to noedit */
|
||||
EXTERN int bslash_quote IZERO;/* PWP: tcsh-style quoting? (in sh.c) */
|
||||
EXTERN int anyerror IZERO; /* propagate errors from pipelines/backq */
|
||||
+EXTERN int tcsh_posix_status IZERO; /* negation for anyerror */
|
||||
EXTERN int compat_expr IZERO;/* csh-style expressions? */
|
||||
EXTERN int isoutatty IZERO; /* is SHOUT a tty */
|
||||
EXTERN int isdiagatty IZERO;/* is SHDIAG a tty */
|
||||
diff --git a/sh.proc.c b/sh.proc.c
|
||||
index f2356d1..e32ebda 100644
|
||||
--- a/sh.proc.c
|
||||
+++ b/sh.proc.c
|
||||
@@ -560,7 +560,7 @@ pjwait(struct process *pp)
|
||||
do {
|
||||
/* In case of pipelines only the result of the last
|
||||
* command should be taken in account */
|
||||
- if (!anyerror && !(fp->p_flags & PBRACE)
|
||||
+ if ((!anyerror || tcsh_posix_status) && !(fp->p_flags & PBRACE)
|
||||
&& ((fp->p_flags & PPOU) || (fp->p_flags & PBACKQ)))
|
||||
continue;
|
||||
if (fp->p_reason)
|
||||
diff --git a/sh.set.c b/sh.set.c
|
||||
index 0f98a2b..8d660e0 100644
|
||||
--- a/sh.set.c
|
||||
+++ b/sh.set.c
|
||||
@@ -109,6 +109,9 @@ update_vars(Char *vp)
|
||||
else if (eq(vp, STRanyerror)) {
|
||||
anyerror = 1;
|
||||
}
|
||||
+ else if (eq(vp, STRtcsh_posix_status)) {
|
||||
+ tcsh_posix_status = 1;
|
||||
+ }
|
||||
else if (eq(vp, STRsymlinks)) {
|
||||
Char *pn = varval(vp);
|
||||
|
||||
@@ -768,6 +771,8 @@ unset(Char **v, struct command *c)
|
||||
loginsh = 0;
|
||||
if (adrof(STRanyerror) == 0)
|
||||
anyerror = 0;
|
||||
+ if (adrof(STRtcsh_posix_status) == 0)
|
||||
+ tcsh_posix_status = 0;
|
||||
if (adrof(STRwordchars) == 0)
|
||||
word_chars = STR_WORD_CHARS;
|
||||
if (adrof(STRedit) == 0)
|
||||
diff --git a/tc.const.c b/tc.const.c
|
||||
index 641e234..d942542 100644
|
||||
--- a/tc.const.c
|
||||
+++ b/tc.const.c
|
||||
@@ -44,6 +44,8 @@ Char STRrootdefautologout[] = { '1', '5', '\0' };
|
||||
Char STRautomatic[] = { 'a', 'u', 't', 'o', 'm', 'a', 't', 'i', 'c',
|
||||
'\0' };
|
||||
Char STRanyerror[] = { 'a', 'n', 'y', 'e', 'r', 'r', 'o', 'r', '\0' };
|
||||
+Char STRtcsh_posix_status[] = {'t', 'c', 's', 'h', '_', 'p', 'o', 's', 'i', 'x',
|
||||
+ '_', 's', 't', 'a', 't', 'u', 's', '\0' };
|
||||
Char STRhangup[] = { 'h', 'a', 'n', 'g', 'u', 'p', '\0' };
|
||||
Char STRaout[] = { 'a', '.', 'o', 'u', 't', '\0' };
|
||||
Char STRtty[] = { 't', 't', 'y', '\0' };
|
||||
diff --git a/tests/variables.at b/tests/variables.at
|
||||
index 424e4da..f270e59 100644
|
||||
--- a/tests/variables.at
|
||||
+++ b/tests/variables.at
|
||||
@@ -937,6 +937,34 @@ AT_CHECK([tcsh -f -c 'echo $?tcsh'], ,
|
||||
AT_CLEANUP
|
||||
|
||||
|
||||
+AT_SETUP([$ tcsh_posix_status])
|
||||
+
|
||||
+AT_DATA([exit_status.csh],
|
||||
+[[echo $?tcsh_posix_status
|
||||
+false | true ; echo $?
|
||||
+set tcsh_posix_status = 1 ; echo $?tcsh_posix_status $tcsh_posix_status
|
||||
+false | true ; echo $?
|
||||
+set tcsh_posix_status = 0 ; echo $?tcsh_posix_status $tcsh_posix_status
|
||||
+# Note it is still set!
|
||||
+false | true ; echo $?
|
||||
+unset tcsh_posix_status ; echo $?tcsh_posix_status
|
||||
+false | true ; echo $?
|
||||
+]])
|
||||
+
|
||||
+AT_CHECK([tcsh -f exit_status.csh],,
|
||||
+[0
|
||||
+1
|
||||
+1 1
|
||||
+0
|
||||
+1 0
|
||||
+0
|
||||
+0
|
||||
+1
|
||||
+])
|
||||
+
|
||||
+AT_CLEANUP
|
||||
+
|
||||
+
|
||||
AT_SETUP([$ term])
|
||||
|
||||
AT_DATA([term.csh],
|
||||
--
|
||||
1.9.3
|
||||
|
@ -1,123 +0,0 @@
|
||||
From 8536e50f22f1fb04aed035e48661632f263b2606 Mon Sep 17 00:00:00 2001
|
||||
From: Jaromír Končický <jkoncick@redhat.com>
|
||||
Date: Wed, 27 Aug 2014 13:56:19 +0200
|
||||
Subject: [PATCH 13/14] Changed 'anyerror' variable to 'tcsh_posix_status' with
|
||||
opposite meaning
|
||||
|
||||
---
|
||||
sh.c | 2 --
|
||||
sh.h | 2 +-
|
||||
sh.proc.c | 6 +++---
|
||||
sh.set.c | 8 ++++----
|
||||
tc.const.c | 2 +-
|
||||
tcsh.man | 12 ++++--------
|
||||
6 files changed, 13 insertions(+), 19 deletions(-)
|
||||
|
||||
diff --git a/sh.c b/sh.c
|
||||
index f897317..322a5c6 100644
|
||||
--- a/sh.c
|
||||
+++ b/sh.c
|
||||
@@ -351,8 +351,6 @@ main(int argc, char **argv)
|
||||
PRCHROOT = '#'; /* likewise for root */
|
||||
word_chars = STR_WORD_CHARS;
|
||||
bslash_quote = 0; /* PWP: do tcsh-style backslash quoting? */
|
||||
- anyerror = 1; /* for compatibility */
|
||||
- setcopy(STRanyerror, STRNULL, VAR_READWRITE);
|
||||
|
||||
/* Default history size to 100 */
|
||||
setcopy(STRhistory, str2short("100"), VAR_READWRITE);
|
||||
diff --git a/sh.h b/sh.h
|
||||
index 4e3f13c..7d31db9 100644
|
||||
--- a/sh.h
|
||||
+++ b/sh.h
|
||||
@@ -596,7 +596,7 @@ EXTERN int havhash IZERO; /* path hashing is available */
|
||||
EXTERN int editing IZERO; /* doing filename expansion and line editing */
|
||||
EXTERN int noediting IZERO; /* initial $term defaulted to noedit */
|
||||
EXTERN int bslash_quote IZERO;/* PWP: tcsh-style quoting? (in sh.c) */
|
||||
-EXTERN int anyerror IZERO; /* propagate errors from pipelines/backq */
|
||||
+EXTERN int tcsh_posix_status IZERO; /* POSIX-like error $status behaviour */
|
||||
EXTERN int compat_expr IZERO;/* csh-style expressions? */
|
||||
EXTERN int isoutatty IZERO; /* is SHOUT a tty */
|
||||
EXTERN int isdiagatty IZERO;/* is SHDIAG a tty */
|
||||
diff --git a/sh.proc.c b/sh.proc.c
|
||||
index f2356d1..c425845 100644
|
||||
--- a/sh.proc.c
|
||||
+++ b/sh.proc.c
|
||||
@@ -558,9 +558,9 @@ pjwait(struct process *pp)
|
||||
reason = 0;
|
||||
fp = pp;
|
||||
do {
|
||||
- /* In case of pipelines only the result of the last
|
||||
- * command should be taken in account */
|
||||
- if (!anyerror && !(fp->p_flags & PBRACE)
|
||||
+ /* In case of POSIX-like behaviour, only the result of the last
|
||||
+ * command in pipeline/backq should be taken in account */
|
||||
+ if (tcsh_posix_status && !(fp->p_flags & PBRACE)
|
||||
&& ((fp->p_flags & PPOU) || (fp->p_flags & PBACKQ)))
|
||||
continue;
|
||||
if (fp->p_reason)
|
||||
diff --git a/sh.set.c b/sh.set.c
|
||||
index 0f98a2b..1096460 100644
|
||||
--- a/sh.set.c
|
||||
+++ b/sh.set.c
|
||||
@@ -106,8 +106,8 @@ update_vars(Char *vp)
|
||||
else if (eq(vp, STRloginsh)) {
|
||||
loginsh = 1;
|
||||
}
|
||||
- else if (eq(vp, STRanyerror)) {
|
||||
- anyerror = 1;
|
||||
+ else if (eq(vp, STRtcsh_posix_status)) {
|
||||
+ tcsh_posix_status = 1;
|
||||
}
|
||||
else if (eq(vp, STRsymlinks)) {
|
||||
Char *pn = varval(vp);
|
||||
@@ -766,8 +766,8 @@ unset(Char **v, struct command *c)
|
||||
HistLit = 0;
|
||||
if (adrof(STRloginsh) == 0)
|
||||
loginsh = 0;
|
||||
- if (adrof(STRanyerror) == 0)
|
||||
- anyerror = 0;
|
||||
+ if (adrof(STRtcsh_posix_status) == 0)
|
||||
+ tcsh_posix_status = 0;
|
||||
if (adrof(STRwordchars) == 0)
|
||||
word_chars = STR_WORD_CHARS;
|
||||
if (adrof(STRedit) == 0)
|
||||
diff --git a/tc.const.c b/tc.const.c
|
||||
index 641e234..4d0c9e3 100644
|
||||
--- a/tc.const.c
|
||||
+++ b/tc.const.c
|
||||
@@ -43,7 +43,7 @@ Char STRrootdefautologout[] = { '1', '5', '\0' };
|
||||
#endif
|
||||
Char STRautomatic[] = { 'a', 'u', 't', 'o', 'm', 'a', 't', 'i', 'c',
|
||||
'\0' };
|
||||
-Char STRanyerror[] = { 'a', 'n', 'y', 'e', 'r', 'r', 'o', 'r', '\0' };
|
||||
+Char STRtcsh_posix_status[] = { 't', 'c', 's', 'h', '_', 'p', 'o', 's', 'i', 'x', '_', 's', 't', 'a', 't', 'u', 's', '\0' };
|
||||
Char STRhangup[] = { 'h', 'a', 'n', 'g', 'u', 'p', '\0' };
|
||||
Char STRaout[] = { 'a', '.', 'o', 'u', 't', '\0' };
|
||||
Char STRtty[] = { 't', 't', 'y', '\0' };
|
||||
diff --git a/tcsh.man b/tcsh.man
|
||||
index 8cc45c8..1e585a8 100644
|
||||
--- a/tcsh.man
|
||||
+++ b/tcsh.man
|
||||
@@ -4356,14 +4356,10 @@ Reset to 1 in login shells.
|
||||
See also \fBloginsh\fR.
|
||||
.TP 8
|
||||
.B status
|
||||
-The status returned by the last command, unless the variable
|
||||
-.B anyerror
|
||||
-is set, and any error in a pipeline or a backquote expansion will be
|
||||
-propagated (this is the default
|
||||
-.B csh
|
||||
-behavior, and the current
|
||||
-.B tcsh
|
||||
-default). If it terminated
|
||||
+The status of any error in a pipeline or a backquote expansion that is
|
||||
+propagated as a result `status', unless `tcsh_posix_status'
|
||||
+variable is set, and only the last command status is taken in account
|
||||
+(the latter is default behaviour in POSIX-like shells). If it terminated
|
||||
abnormally, then 0200 is added to the status. Builtin commands
|
||||
which fail return exit status `1', all other builtin commands
|
||||
return status `0'.
|
||||
--
|
||||
1.9.3
|
||||
|
@ -23,7 +23,7 @@ Patch33: tcsh-6.18.00-history-merge.patch
|
||||
Patch34: tcsh-6.18.01-repeated-words-man.patch
|
||||
# Proposed upstream - http://mx.gw.com/pipermail/tcsh-bugs/2013-April/000833.html
|
||||
Patch35: tcsh-6.18.01-elf-interpreter.patch
|
||||
Patch36: tcsh-6.18.01-posix-exit-status-value.patch
|
||||
Patch36: tcsh-6.18.01-introduce-tcsh_posix_status.patch
|
||||
Patch37: tcsh-6.18.01-reverse-history-handling-in-loops.patch
|
||||
Patch38: tcsh-6.18.01-skip-tty-tests.patch
|
||||
|
||||
@ -135,6 +135,7 @@ fi
|
||||
- use the %%autosetup macro
|
||||
- enable testsuite in %%check
|
||||
- skip tests which are not able to be run without tty
|
||||
- support both $anyerror & $tcsh_posix_status (#1129703)
|
||||
|
||||
* Mon Aug 18 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 6.18.01-11
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild
|
||||
|
Loading…
Reference in New Issue
Block a user