Skip to content

Commit 7d44f1d

Browse files
committed
Fix !^:h and !^:t failing when no / found
Restore the behavior where both !^:h and !^:t return the whole string when there is no / in !^ (or other similar history reference). Related commits: - ccd1e6d - 05d3d6b
1 parent 617359c commit 7d44f1d

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

Fixes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
36. Fix !^:h and !^:t failing when no / found (Kimmo Suominen)
12
35. Add cross-build support for gethost (josefs10)
23
34. Add support for $?< (Matheus Garcia)
34
33. V6.24.12 - 2024-04-05

sh.lex.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,7 @@ domod(Char *cp, Char type)
10691069
case 't':
10701070
wp = Strrchr(cp, '/');
10711071
if (wp == NULL)
1072-
return NULL;
1072+
return Strsave(cp);
10731073
if (type == 't')
10741074
xp = Strsave(wp + 1);
10751075
else

tests/lexical.at

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,10 @@ AT_DATA([modifiers.csh],
455455
[[echo foo bar baz quux /usr/src/sys/sys/malloc.c
456456
^baz^bash
457457
^bar^kPa^:p
458+
echo !1:1:h
459+
echo !1:1:t
460+
echo !1:1:r
461+
echo !1:1:e
458462
echo !1:$:h
459463
echo !1:$:t
460464
echo !1:$:r
@@ -480,6 +484,10 @@ echo ${#var}
480484
AT_CHECK([tcsh -f -q -i < modifiers.csh], ,
481485
[[> foo bar baz quux /usr/src/sys/sys/malloc.c
482486
foo bar bash quux /usr/src/sys/sys/malloc.c
487+
foo
488+
foo
489+
foo
490+
483491
/usr/src/sys/sys
484492
malloc.c
485493
/usr/src/sys/sys/malloc
@@ -501,6 +509,10 @@ f[oo][oo] bar baz quux /usr/src/sys/sys/mall[oo]c.c
501509
]],
502510
[[echo foo bar bash quux /usr/src/sys/sys/malloc.c
503511
echo foo kPa bash quux /usr/src/sys/sys/malloc.c
512+
echo foo
513+
echo foo
514+
echo foo
515+
echo
504516
echo /usr/src/sys/sys
505517
echo malloc.c
506518
echo /usr/src/sys/sys/malloc

0 commit comments

Comments
 (0)