Timeline for Bash giving me : Too many arguments error
Current License: CC BY-SA 4.0
7 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jan 16, 2020 at 20:56 | comment | added | stonewareslord |
@Tomaz is incorrect (though I could not find the referenced post). [ is not bash syntax and you cannot use && inside since [ is a command. bash syntax ([[) does support using && and || inside its test operators. Regardless, testing -n has no effect in this particular case
|
|
| Dec 10, 2018 at 18:54 | history | edited | Rui F Ribeiro | CC BY-SA 4.0 |
added 364 characters in body
|
| Dec 10, 2018 at 18:50 | comment | added | Rui F Ribeiro |
@Kusalananda taken from a script of mine here using jq too: if [ x"$S" == x"null" ] # end of array
|
|
| Dec 10, 2018 at 18:46 | comment | added | Rui F Ribeiro |
@Kusalananda Yeah, I just wrote this for the benefit of the understanding and syntax of the OP, besides being short in time. I also noticed the first condition is redundant. As for the actual string "null", some utilities indeed return "null" as a full string, in specific situations when they have nothing else to return or have not met a condition...jq is one of them, for instance, and in the past I found more doing that.
|
|
| Dec 10, 2018 at 18:10 | comment | added | Kusalananda♦ |
It seems as if the -n test is not needed. If the variable contains no value, it will not be equal to the string null (if that is supposed to be a string at all, sometimes people seems to thing it's a special value that denotes "no value").
|
|
| Dec 9, 2018 at 21:01 | vote | accept | Salhi Fadhel | ||
| Dec 9, 2018 at 20:59 | history | answered | Rui F Ribeiro | CC BY-SA 4.0 |