<p>I am using zsh with oh-my-zsh and I put an entry into my ~/.zshrc to have a shortcut for the option <code>--dry-run=client -o yaml</code> as a variable and be faster for generating yaml files with imperative commands
when I enter for example <code>kubectl run test-pod --image=nginx $do</code> I get the error <code>error: Invalid dry-run value (client -o yaml). Must be &quot;none&quot;, &quot;server&quot;, or &quot;client&quot;.</code> as if the equal operator has not been read.
it works fine with bash</p>
<p>I am using kubectl plugin for auto-completion</p>
<p>my zshrc:</p>
<pre><code>plugins=(git docker kubectl docker-compose ansible zsh-autosuggestions zsh-syntax-highlighting sudo terraform zsh-completions)


alias ls=&quot;exa --icons --group-directories-first&quot;
alias ls -l=&quot;exa --icons --group-directories-first -lg&quot;
alias ll=&quot;exa --icons --group-directories-first -lg&quot;
alias cat=&quot;ccat --bg=dark -G Plaintext=brown -G Punctuation=white&quot;

export PATH=$PATH:/usr/local/go/bin

# create yaml on-the-fly faster
export do='--dry-run=client -o yaml'
</code></pre>
<p>my bashrc:</p>
<pre><code># enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
  if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
  elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
  fi
fi

export do='--dry-run=client -o yaml'
</code></pre>
<p>and when I execute the command it works fine</p>
<pre><code>$ kubectl run test-pod --image=nginx $do
apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: test-pod
  name: test-pod
spec:
  containers:
  - image: nginx
    name: test-pod
    resources: {}
  dnsPolicy: ClusterFirst
  restartPolicy: Always
status: {}
</code></pre>

tba
<p>As @Gairfowl metioned The distinction is that word splitting for unquoted parameter expansions is not performed by zsh (by default).</p>
<p>By enabling the SH WORD SPLIT option or by using the = flag on a specific expansion, you can enable &quot;regular&quot; word splitting same as bash. To do that you need to follow this syntax</p>
<pre><code>kubectl run test-pod --image=nginx ${=do}
</code></pre>
<p>or</p>
<pre><code>kubectl run test-pod --image=nginx ${do}
</code></pre>
<p>In case if these two dont work try to use the <code>setopt</code></p>
<pre><code>setopt SH_WORD_SPLIT
kubectl run test-pod --image=nginx $do
</code></pre>
