Reputation: 9203
The following:
#!/bin/sh
FOX="{ab,cd}"
echo $FOX
outputs what I'd expect ({ab,cd}) but:
#!/bin/ksh
FOX="{ab,cd}"
echo $FOX
turns the comma into a space. Why is this? I also cannot seem to escape the comma with '\'.
Upvotes: 2
Views: 607
Reputation: 28049
You're getting brace expansion when $FOX
is evaluated.
From the ksh man page:
For the form {*,*}
:
a field is created for each string between { and ,, between , and ,, and between , and }.
So the shell is taking your comma separated list and expanding it so that it can be used, for example, in a for loop.
As, shellter suggested in the comments, this can be fixed by double-quoting "$FOX"
whenever it is evaluated.
Upvotes: 4