In bash
, unquoted parameter expansions always undergo word-splitting, so if a="foo bar"
, then $a
expands to two words, foo
and bar
. As a command, this means running the command foo
with an argument bar
.
In zsh
, parameter expansions to not undergo word-splitting by default, which means the same expansion $a
would produce a single word foo bar
, treated as the name of the command to execute.
In either case, relying on parameter expansion to "parse" a shell command is fragile; in addition to word-splitting, the expansion is subject to pathname expansion (globbing), and you are limited to simple commands and their arguments. No pipes, lists (&&
, ||
), or redirections allowed, as everything will be treated as the command name and a sequence of arguments.
What you want in both shells is to simply treat your job file as a shell script, which can be executed in the current shell using the .
command:
. jobFile
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…