3 ms·
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 regula
by tsimionescu 6y ago
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.
- teddyh 6y agoThat has nothing to do with spaces, but more to do with the rather lackluster support for arrays in most Bourne-style shells.
- account42 6y agoBash 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 "$@"