Re: expand: Fix ghost fields with unquoted $@/$*

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 23/03/2018 05:37, Herbert Xu wrote:
You're right.  The proper fix to this is to ensure that nulonly
is not set in varvalue for $*.  It should only be set for $@ when
it's inside double quotes.

In fact there is another bug while we're playing with $@/$*.
When IFS is set to a non-whitespace character such as :, $*
outside quotes won't remove empty fields as it should.

That's not limited to empty fields:

  IFS=,
  set -- , ,
  set -- $@
  echo $#

This should print 2, not 3. (bash gets this wrong too.)

This patch fixes both problems.

Also the above. But it breaks a traditional ash extension:

  unset IFS
  set -- A1 B2 C3
  echo ${@%2 C3}

This used to print A1 B, but prints A1 B2 C3 with your patch.

  echo ${@%2}

This used to print A1 B2 C3, but prints A1 B with your patch.

This extension was already pretty much broken within quoted expansions: "${@%2}" would already expand to A1 B. Your patch extends that to the non-quoted case.

I do not know if you want to keep this extension in.

Cheers,
Harald van Dijk
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux