[Tcsh] tcsh Does Not Fully Recognize 'end' In an Alias
Neil R. Ormos
ormos-ts23 at ormos.org
Sun Jan 15 02:32:57 UTC 2023
Tcsh does not appear to fully recognize the 'end' of a 'foreach' loop in an alias.
Consider the alias zzzz, listed below, in which there are three successive 'end' statements, with only a single matching 'foreach' statement. When the alias is run, I would expect tcsh to emit the error message
"end: Not in while/foreach."
for each of the second and third 'end' statements. However, tcsh does not complain about the extra 'end's.
Then, after the alias finishes running, I would expect tcsh to emit the same error message when the first 'end' is typed as input to the shell. However, tcsh does not complain about the first 'end'. The expected error message is emitted only after a second 'end' is typed.
I don't how significant this behavior is. When using tcsh 6.20.00, I have noticed that history list editing sometimes seems to become confused--in that expected history items do not appear when using ^p and ^n (default bindings)--after the alias completes but before the first 'end' is typed. I haven't found a way to reproduce that.
> echo $version
tcsh 6.24.07 (Astron) 2022-12-21 (x86_64-unknown-linux) options wide,nls,dl,al,kan,sm,rh,color,filec
> cat set-alias-zzzz
alias zzzz 'foreach aaa ( 1 2 3 ) \
echo $aaa \
> source set-alias-zzzz
> which zzzz
zzzz: aliased to foreach aaa ( 1 2 3 )
end: Not in while/foreach.
More information about the Tcsh