Giuseppe Bilotta <bilotta78 / hotpop.com> wrote:

> BC> That makes it pretty explicit that 0 = true :-)

> Looks like all shells are optimists! :)

> (Ok, point taken, and no I don't know why. Because it wouldn't be
> that clean otherwise?)

Hi,

I think this is only because of practicality reason.  Unix was written in
C, and because C cannot return multiple values in a function and there is
no built-in type of type "string", the "cheapest" way of returning
something from a function is by returning an int.

In Unix, it is tradition that when everything works well, Unix is quiet,
and when there is some error, Unix tells the user.  So if success is 1 and
failure is 0, Unix cannot easily report the nature of error.  But if it is
reversed, when 0 is success and non-zero is a failure, they have so many
integers that can be used to specify the the type of error.  But well,
then they had to reverse the boolean values in the shell to mean that 0 is
"true" (actually "success") and nonzero as "false" (actually "failure").

Regards,

Bill