View Issue Details

IDProjectCategoryView StatusLast Update
0000088tcshGeneralpublic2019-12-05 01:17
Reportersharifib Assigned Tochristos  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version6.21.00 
Fixed in Version6.22.03 
Summary0000088: :q does not preserve empty strings
DescriptionThe :q modifier appears to skip empty strings. This makes it very difficult to pass verbatim arguments to another program.
Steps To ReproduceMinimal example:
> echo $tcsh
6.21.00
> set arr= ( '1st arg' '' '3rd arg' )
> echo ${#arr}
3
> tcsh -c 'echo ${#argv}' $arr:q
2
> tcsh -c 'echo ${#argv}' '1st arg' '' '3rd arg'
3

Expected result:
3
3
3
Additional InformationThis is not new behavior, but complicates writing scripts that want to maintain and pass a variable number of arguments to other programs, some of which could possibly be empty. For example, something like the env command which may consume some initial arguments but does an exec with the remaining verbatim arguments. In tcsh, attempting to do the same with exec $argv[2-]:q apparently doesn't preserve any of the empty arguments.
TagsNo tags attached.

Activities

sharifib

2019-06-27 01:18

reporter   ~0003256

Another example:
> set arr= ( '1st arg' '' '3rd arg' )
> set arr2= ( $arr:q )
> echo ${#arr}
3
> echo ${#arr2}
2

Expected result:
3
3

christos

2019-08-01 16:05

manager   ~0003276

Fixed, thanks!

christos

2019-11-30 14:52

manager   ~0003337

I had to revert the change because it causes NUL characters inside expanded strings...

christos

2019-12-05 01:17

manager   ~0003338

Committed a new Q modifier so $args:gQ should DTRT.

Issue History

Date Modified Username Field Change
2019-06-27 01:14 sharifib New Issue
2019-06-27 01:18 sharifib Note Added: 0003256
2019-08-01 16:05 christos Assigned To => christos
2019-08-01 16:05 christos Status new => assigned
2019-08-01 16:05 christos Status assigned => resolved
2019-08-01 16:05 christos Resolution open => fixed
2019-08-01 16:05 christos Fixed in Version => 6.22.00
2019-08-01 16:05 christos Note Added: 0003276
2019-11-30 14:52 christos Status resolved => confirmed
2019-11-30 14:52 christos Note Added: 0003337
2019-12-05 01:17 christos Status confirmed => resolved
2019-12-05 01:17 christos Fixed in Version 6.22.00 => 6.22.03
2019-12-05 01:17 christos Note Added: 0003338