bash 是否有 return 分配代码?

Does bash have a return code for assignment?

我对分配是否改变有点困惑$?

到目前为止我尝试了什么:

$ curl --fail http://ftp.redhat.com/redhat/brms/6.2.0/en/source/MD5
curl: (22) The requested URL returned error: 404
$ #I have verified that $? should be 22 at this point
$ var=romeo # Does this change $?
$ echo $? # I expected this to return 22 , but I got zero below
0 

请说明一下。 :)

来自man bash

   ?      Expands to the exit status of the most recently  executed  fore‐
          ground pipeline.

所以作业改变了它。无论你做什么,都会改变它。

$ ls alsdaskkad
ls: cannot access alsdaskkad: No such file or directory
$ echo $?
2
$ echo $?
0
$ echo 1
1
$ echo $?
0

以此类推

正如123所说:

Even echoing the return changes the return!