这个问题是关于将一个变量的全部内容分配给另一个变量。
未使用变量(发送至echo
等)
赋值期间没有进行参数扩展。
我的问题也仅与 POSIX shell 有关(此处未使用数组)。
error="You have an error in your input"
newVar="$error"
# vs.
newVar=$error
# ?
# ??This assignment is the question. It doesn't seem that quotes are
# needed here in order to assign the entire contents of $error to
# a new variable.
# ??(But quotes are required when they're used.)
# ?
printf "%s\n" "$error"
# => You have an error in your …
Run Code Online (Sandbox Code Playgroud)