Why 0 is true but false is 1 in the shell?

后端 未结 10 1021
被撕碎了的回忆
被撕碎了的回忆 2020-11-28 02:29
false; echo $?

The above will output 1, which is contradictory with all other programming languages I know.

Any reason in this

10条回答
  •  有刺的猬
    2020-11-28 03:09

    AFAIK this come from the C convention that you should return 0 if succeded. See:

    man close
    

    Most of the C (POSIX) api is build like this. http://en.wikipedia.org/wiki/C_POSIX_library

提交回复
热议问题