Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • my output is different... Commented Jun 2, 2020 at 12:43
  • you did not quote $str - even if "$str" you just give printable chars like \"b c\" and not actually quoted string "b c" (only eval would execute quotes) Commented Jun 2, 2020 at 12:47
  • @pLumo Do you also get two different arrays? Commented Jun 2, 2020 at 12:47
  • Sure. The quotes are taken literal and have no special meaning for the variable, they are just a character like any other. While when assigning the array using quotes, the quotes are evaluated from your shell to separate the arguments. Commented Jun 2, 2020 at 12:52
  • 1
    What are you trying to do in the end? Can you skip the string variable and just do array=(a "b c" d)? Commented Jun 2, 2020 at 12:55