# BUG? -> sh: [ "$@" ] -> "eats"  it's quotes!



## Seeker (Nov 10, 2011)

If *[ "$@" ]* is alone, err won't show up, but if you compare it ...


```
debug_fun ()
{
    local -
    set -x

    [ "$1" ] && echo '$1 - Empty!'
    [ "$*" ] && echo '$* - Empty!'
    [ "$@" ] && echo '$@ - Empty!'
}


debug_fun_compare ()
{
    local -
    set -x

    [ "$1" = ro ] && echo '$1 - Empty!'
    [ "$*" = ro ] && echo '$* - Empty!'
    [ "$@" = ro ] && echo '$@ - Empty!'
}


debug_fun

debug_fun_compare
```


----------



## SirDice (Nov 10, 2011)

Not a bug.

http://www.grymoire.com/Unix/Sh.html#uh-42


----------



## Seeker (Nov 10, 2011)

SirDice said:
			
		

> Not a bug.
> 
> http://www.grymoire.com/Unix/Sh.html#uh-42


I know all this and it *doesn't* give an answer to this.
I'm talking about *0* args here *in quotes* (as $@ and $*, both behave same, when NOT surrounded with "").


----------



## jilles@ (Nov 13, 2011)

[ is expanded like any other simple command. The three tests in your first function are not all expanded the same but all are valid tests returning false. The third test in your second function causes a test(1)() syntax error because "$@" expands to nothing at all if there are no positional parameters.


----------



## Seeker (Nov 13, 2011)

That is exactly, why do I use double quotes around vars, to prevent syntax errors, in case when var isn't set/is undefined.
Problem is, "$@" acts like it was written as $@. It's double quotes disappear (Exposed via set -x in *both* functions)


----------

