0

I want to use:

  schema=$(kubectl exec -n $namespace -it  $podName -- bash -c "./spiral orm:schema")
  echo $schema

But eventually in schema variable recorded only the first line from the result of bash execution. How to make it use all lines?

Nico Nekoru
  • 2,402
  • 1
  • 15
  • 32
ogbofjnr
  • 1,237
  • 2
  • 15
  • 29
  • 1
    Cannot reproduce. What does `kubectl ...` print for you? Does adding quotes solve the issue? (`echo "$schema"` keeps newlines in `$schema`; `echo $schema` does not.) – Socowi May 14 '20 at 11:31
  • @Socowi, quotes helped! What was that? – ogbofjnr May 14 '20 at 11:51
  • [I just assigned a variable but `echo $variable` shows something else](https://stackoverflow.com/questions/29378566/i-just-assigned-a-variable-but-echo-variable-shows-something-else) is also [BashPitfalls #14](http://mywiki.wooledge.org/BashPitfalls#echo_.24foo). – Charles Duffy May 15 '20 at 14:52
  • 1
    BTW, if you run your original code through http://shellcheck.net/, it'll give you (among others) the warning [SC2086](https://github.com/koalaman/shellcheck/wiki/SC2086), describing the same bug. – Charles Duffy May 15 '20 at 14:54

0 Answers0