Hacker News new | past | comments | ask | show | jobs | submit login

The shell (bash, anyway) has a weird mix of support and lack of support for spaces/lists/etc.

For example, there is no way to store the `a b "c d"` in a regular variable in a way where you can then call something similar to `ls $VAR` and get the equivalent of `ls a b "c d"`. You can either get the behavior of `ls a b c d` or `ls "a b c d"`, but if you need `ls a b "c d"` you must go for an array variable with new syntax. This isn't necessarily a big hurdle, but it indicates that the concepts are hard to grasp and possibly inconsistent.




Bash has arrays:

    var=( a b "c d" )
    ls "${var[@]}"
POSIX shell can get you what you want with eval:

    var='a b "c d"'
    eval "ls $var"
There is also one array variable in POSIX shells, the argument list:

    set -- a b "c d"
    ls "$@"


That has nothing to do with spaces, but more to do with the rather lackluster support for arrays in most Bourne-style shells.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: