shells/tcsh: restore the behavior where $foo:h returns the whole string

Cherry-picked from upstream.
Bug reported by Alessandro De Laurenzis.
This commit is contained in:
naddy 2021-03-27 16:54:22 +00:00
parent f5ca73ac23
commit 4c8b1f36aa
3 changed files with 45 additions and 1 deletions

View File

@ -1,8 +1,9 @@
# $OpenBSD: Makefile,v 1.62 2021/01/28 20:24:56 naddy Exp $
# $OpenBSD: Makefile,v 1.63 2021/03/27 16:54:22 naddy Exp $
COMMENT= extended C-shell with many useful features
DISTNAME= tcsh-6.22.03
REVISION= 0
CATEGORIES= shells
HOMEPAGE= http://www.tcsh.org/

View File

@ -0,0 +1,17 @@
$OpenBSD: patch-sh_lex_c,v 1.1 2021/03/27 16:54:23 naddy Exp $
Restore the behavior where both $foo:h and $foo:t return the whole string
https://github.com/tcsh-org/tcsh/commit/05d3d6bfc22462584f9347493499621056995ac1
Index: sh.lex.c
--- sh.lex.c.orig
+++ sh.lex.c
@@ -1046,7 +1046,7 @@ domod(Char *cp, Char type)
case 't':
wp = Strrchr(cp, '/');
if (wp == NULL)
- return Strsave(type == 't' ? cp : STRNULL);
+ return NULL;
if (type == 't')
xp = Strsave(wp + 1);
else

View File

@ -0,0 +1,26 @@
$OpenBSD: patch-tests_lexical_at,v 1.1 2021/03/27 16:54:23 naddy Exp $
Restore the behavior where both $foo:h and $foo:t return the whole string
https://github.com/tcsh-org/tcsh/commit/05d3d6bfc22462584f9347493499621056995ac1
Index: tests/lexical.at
--- tests/lexical.at.orig
+++ tests/lexical.at
@@ -677,7 +677,7 @@ AT_CHECK([tcsh -f colon_r_no_extension.csh], 0,
AT_CLEANUP
-AT_SETUP([$x:q:h does not cause out of memory crash and yields nothing])
+AT_SETUP([$x:q:h does not cause out of memory crash and yields the full string])
AT_DATA([x_colon_q_colon_h.csh],
[[set x='a/b c/d.e'
@@ -686,7 +686,7 @@ exit 0
]])
AT_CHECK([tcsh -f x_colon_q_colon_h.csh], 0,
-[
+[a/b c/d.e
])
AT_CLEANUP