[Tcsh] TCSH 6.22 ":q" on empty string truncation bug

Christos Zoulas christos at zoulas.com
Fri Nov 29 20:21:09 UTC 2019


Yup, this is going to be hard to fix; we should revert the change...

diff --git a/sh.lex.c b/sh.lex.c
index 2893768..1b812b8 100644
--- a/sh.lex.c
+++ b/sh.lex.c
@@ -1022,8 +1022,6 @@ domod(Char *cp, Char type)
 
     case 'q':
     case 'x':
-       if (*cp == '\0')
-           return Strsave(STRQNULL);
        wp = Strsave(cp);
        for (xp = wp; (c = *xp) != 0; xp++)
            if ((c != ' ' && c != '\t') || type == 'q')


> On Nov 29, 2019, at 5:10 AM, Jamie Landeg-Jones <jamie at catflap.org> wrote:
> 
> Hiya. On upgrading to tcsh 6.22, many of my scripts started to fail.
> 
> I tracked it down to ":q" on an empty string causing the rest of the line to be ignored.
> 
> Things were fine on 6.21 and earlier.
> 
> Here is a simplified example showing the issue:
> 
> Cheers, Jamie
> 
> File "test":
> 
> set test1="boo"
> set test2=""
> alias test1 "echo "\""$test1:q"\"" is working."
> alias test2 "echo "\""$test2:q"\"" is working."
> alias test3 "echo "\""$test1"\"" is working."
> alias test4 "echo "\""$test2"\"" is working."
> 
> alias | grep '^test[1-4]'
> 
> -----------------------------------------------------
> tcsh v6.21:
> 
> % echo $version
> tcsh 6.21.00 (Astron) 2019-05-08 (x86_64-amd-FreeBSD) options wide,nls,dl,al,kan,rh,color,filec
> 
> % source test
> test1   echo "boo" is working.
> test2   echo "" is working.
> test3   echo "boo" is working.
> test4   echo "" is working.
> 
> -----------------------------------------------------
> tcsh v6.22:
> 
> % echo $version
> tcsh 6.22.00 (Astron) 2019-11-28 (x86_64-amd-FreeBSD) options wide,nls,dl,al,kan,rh,color,filec
> 
> % source test
> test1   echo "boo" is working.
> test2   echo "
> test3   echo "boo" is working.
> test4   echo "" is working.
> 
> -- 
> Tcsh mailing list
> Tcsh at astron.com
> https://mailman.astron.com/mailman/listinfo/tcsh



More information about the Tcsh mailing list