bug-bash
[Top][All Lists]
Advanced

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

Re: "${x-"$@"}" expansion


From: Grisha Levit
Subject: Re: "${x-"$@"}" expansion
Date: Wed, 27 Apr 2016 07:33:25 -0400

Sorry that wasn’t very clear. I only included that case to demonstrate that seemingly contradictory things are happening:

  • "address@hidden" expands each positional parameter to a separate word, following the usual "$@" behavior
  • The usual "$@" behavior is to expand to 0 words if there are no positional params but in this case "address@hidden" expands to an empty string instead
  • If we interpret "address@hidden" as being equivalent to "${_+}" when there are no params, then the two cases above seem reconcilable, but still "address@hidden" expanding to nothing does not make sense.

I suspect the below is not really the desired behavior?

fun() { echo $#; }

fun "$@"
0
fun "address@hidden"
1
fun "address@hidden"
0
fun "address@hidden"
1
fun "address@hidden"
0
fun "address@hidden"
1

FWIW bash 4.1 and below treat all but the first case as one word.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]