title: Why are some commands are wrongly wrapped in single quotes?
body: <p>From looking at the <code>set -x</code> output it appears the 3 commands after <code>cut</code> are wrapped in single quotes. Looking at the script, they should not be; they should be preceded by the <code>+</code> operator.</p>
  
  <p>This assumes a few things of course:</p>
  
  <ol>
  <li>This isn't about Vault, it's about the weird Bash behavior</li>
  <li><code>kubectl port-forward</code> has executed successfully</li>
  <li>Vault Has been initialized and is ready to be unsealed</li>
  </ol>
  
  <p><strong><em>Why are these commands being wrapped in single quotes?</em></strong></p>
  
  <p>Some factors:</p>
  
  <ul>
  <li>Occurs on macOS Mojave</li>
  <li>Installed/upgraded GNU Bash via Homebrew</li>
  <li>Using macOS Terminal</li>
  </ul>
  
  <pre><code>#!/usr/bin/env bash                                                                
  # https://www.vaultproject.io
  
  export VAULT_ADDR='http://127.0.0.1:8200'
  theJelly='/tmp/jelly.out'
  podVault='vault-0'
  
  ###---
  ### Unseal
  ###---
  echo "Unsealing the Vault..."
  set -x
  unsealKey="$(grep Unseal $theJelly | cut -d' ' -f4)"
  echo "$unsealKey"
  kubectl exec -t "$podVault" -- vault operator unseal "$unsealKey"
  
  
  vault status
  
  
  ######################################################################################
  # OUTPUT
  # Why are the commands (after cut) preceded with a single quote?
  ######################################################################################
  $ sudo /var/tmp/vaultest.sh
  Unsealing the Vault...
  ++ grep Unseal /tmp/jelly.out
  ++ cut '-d ' -f4
  ' unsealKey='blah=                                        # &lt;-- why ' unsealKey=' ?
  ' echo 'blah=                                             # &lt;-- why ' echo '
  blah=
  ' kubectl exec -t vault-0 -- vault operator unseal 'blah= # &lt;-- why ' kubectl ... '
  The connection to the server localhost:8080 was refused - did you specify the right host or port?
  + vault status                                            # &lt;-- then it's okay again?!
  Key                Value
  ---                -----
  Seal Type          shamir
  Initialized        true
  Sealed             true
  Total Shares       1
  Threshold          1
  Unseal Progress    0/1
  Unseal Nonce       n/a
  Version            1.3.2
  HA Enabled         false
  
  ######################################################################################
  # JELLY - just an ASCII text file
  ######################################################################################
  HOST:~ tester$ cat -vte /tmp/jelly.out 
  ^[[0mUnseal Key 1: blah=^[[0m^M$
  ^[[0m^[[0m^M$
  ^[[0mInitial Root Token: s.FOO^[[0m^M$
  ^[[0m^[[0m^M$
  ^[[0mVault initialized with 1 key shares and a key threshold of 1. Please securely^M$
  distribute the key shares printed above. When the Vault is re-sealed,^M$
  restarted, or stopped, you must supply at least 1 of these keys to unseal it^M$
  before it can start servicing requests.^[[0m^M$
  ^[[0m^[[0m^M$
  ^[[0mVault does not store the generated master key. Without at least 1 key to^M$
  reconstruct the master key, Vault will remain permanently sealed!^[[0m^M$
  ^[[0m^[[0m^M$
  ^[[0mIt is possible to generate new unseal keys, provided you have a quorum of^M$
  existing unseal keys shares. See "vault operator rekey" for more information.^[[0m^M$
  </code></pre>
  
  <p><em>If these actions (below) are done manually they totally work; eg: (minus the single quotes)</em></p>
  
  <p><code>kubectl exec -t vault-0 -- vault operator unseal blah=</code></p>
  
  <p>Some diagnostic steps:</p>
  
  <ul>
  <li>created a new user to execute the script; user has default env vars. </li>
  <li>installed/upgraded iTerm2 to try something in addition to Terminal</li>
  <li>still got the same result with new user/terminal.</li>
  <li>wrote another script with similar actions (bash expansion assigned to variable)</li>
  </ul>
  
  <pre><code># similar script
  $ cat /tmp/yo.sh
  #!/usr/bin/env bash
  set -x
  
  yoOut='/tmp/yo.out'
  
  yeOut="$(grep ye $yoOut | cut -d' ' -f4)"
  
  echo "$yeOut"
  
  # data file
  $ cat /tmp/yo.out
  ya
  ye1 ye2 ye3 ye4
  yi
  yo
  yu
  
  # set -x output looks normal
  $ /tmp/yo.sh
  + yoOut=/tmp/yo.out
  ++ grep ye /tmp/yo.out
  ++ cut '-d ' -f4
  + yeOut=ye4
  + echo ye4
  ye4
  </code></pre>
  
  <p>This is how we would expect the output to look. </p>
  
  <p>Please help, this issue is driving me bonkers.</p>