应该避免使用 eval。 当用于给变量赋值时,Eval 解析输入,并且能够设置变量,但无法检查这些变量是什么。
# What does this set? # Did it succeed? In part or whole? eval $(set_my_variables) # What happens if one of the returned values has a space in it? variable="$(eval some_function)"