Wednesday, November 16, 2011

Arithmetic Expressions in Shell Scripts

Mark Dominus:

I had assumed that bc was a later development than expr, but it appeared in Unix version 6, while expr did not appear until version 7. So then I thought perhaps expr had been thrown in as a demonstration of yacc, but no, yacc was already present in version 5, and anyway, bc was written with yacc. So I no longer have any workable theory about who perpetrated expr, or why.

2 Comments RSS · Twitter


I emailed Doug McIlroy about it, and he said that expr might have been an earlier invention, by the PWB group, that was not put into research Unix until later on. He also pointed me at some references, which I will check into.

Thanks for your interest in my article. Also thanks for your review of my book, which is still my favorite thing that anyone has ever said about it.


@Mark Thanks for the follow-up. I’d been wondering about expr and its limitations pretty much since I started reading about shell scripting.

For those missing the context, the book is Higher-Order Perl. I highly recommend it, and it’s more relevant to Mac development now that Objective-C has blocks.

Leave a Comment