Package: tcsh
Version: 6.18.01-3
Severity: normal

Dear Maintainer,

Expansion of nested aliases usually works as I
would expect...

.... but not when the nested alias is called from
within an if/then/else/endif statement.

The problem is demonstrated in the following
transcript between the "####" lines.  Lines
beginning with "##" are my comments added later,
and were not typed in to the shell.

I have observed the same behavior the versions
listed below on Debian systems and also in an old
Sun Solaris environment to which I have access:

  tcsh 6.12.00 on Sun Solaris;
  tcsh 6.17.02 on Squeeze;
  tcsh 6.18.01 on Wheezy;
  tcsh 6.18.01 on Jessie; and
  tcsh 6.20.00 (compiled by me) on Jessie.

I am reporting here because the published upstream
reporting channel appears to be out of service.

Best regards,

--Neil Ormos

############################################################

Script started on Tue Dec 26 10:48:56 2017

> unalias jjj
> unalias kkk

## Define kkk, a short alias containing only a
## trivial echo statement.

> alias kkk echo 'Trivial echo statement in an alias.'
> alias kkk
echo Trivial echo statement in an alias.

## Run kkk.

> kkk
Trivial echo statement in an alias.

## Output was what I expected.

## Run the following series of commands including
## an if/then/else statement.  I expect only the
## else part to be executed.  The else part
## includes a plain echo statement and an
## invocation of kkk alias, which I expect to be
## be expanded as above:
##
## set xxx=0
## if ( $xxx ) then
##   echo "The then part."
##   kkk a
## else
##   echo "The else part."
##   kkk b
## endif

> set xxx=0
> if ( $xxx ) then
if?   echo "The then part."
if?   kkk a
if? else
>   echo "The else part."
The else part.
>   kkk b
Trivial echo statement in an alias. b
> endif

## Output was what I expected. Both the plain echo
## statement and the kkk alias ran, and no error
## message was printed.

## Define jjj, an alias intended to be equivalent
## to the prior series of commands.

> alias jjj 'set xxx=0\
? if ( $xxx ) then\
?   echo "The then part."\
?   kkk a\
? else\
?   echo "The else part."\
?   kkk b\
? endif'
> alias jjj
set xxx=0
if ( $xxx ) then
  echo "The then part."
  kkk a
else
  echo "The else part."
  kkk b
endif

## Run jjj. Again, I expect only the else part to be executed.

> jjj
The else part.
endif: Too many arguments.

## The plain echo statement worked correctly.
## However, the invocation of alias kkk did not
## work correctly, and tcsh printed the error
## message "endif: Too many arguments."

> exit
exit

Script done on Tue Dec 26 10:52:02 2017

############################################################


-- System Information:
Debian Release: 8.10
  APT prefers oldstable-updates
  APT policy: (500, 'oldstable-updates'), (500, 'oldstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.16.0-4-amd64 (SMP w/8 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=ANSI_X3.4-1968) 
(ignored: LC_ALL set to C)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages tcsh depends on:
ii  libc6      2.19-18+deb8u10
ii  libtinfo5  5.9+20140913-1+deb8u2

tcsh recommends no packages.

tcsh suggests no packages.

-- no debconf information

Reply via email to