GNU Hello
Homepage | Download (422 KB)
Version: 2.3
License: GPL3
Rating: 
It has long been a tradition to begin programming books with a simple program that prints the words “Hello, World!” to the screen. Among those who write programming books, at least.
Brian Kernighan seems to have been the history-making person who wrote the very first ‘hello’ program. His original masterpiece appeared in a Bell Labs Tech Report, entitled The Programming Language B, in 1973. He later went on to co-write the first book on the C programming language (which was given the very clever title The C Programming Language), which included another such program, and things took off from there.
In keeping with the tech-book writerly tradition, this software blog also begins with a “Hello, World!” of sorts — A review of the GNU hello command!
The people at GNU noticed that the ‘hello’ program was unavailable to nonprogrammers. You couldn’t buy it in software shops, and it wasn’t available free anywhere, either. Rather than deprive such a significant percentage of the population of such a handy computer science tool, they created the GNU hello package, and released it under the GNU public license, so that all people would be able to run it for free, in perpetuity.
Or so the story goes.
The boring truth is that it is designed to be an example of what a GNU program ought to be like, and a model for the GNU coding standards. Because it’s written in such a way as to be easy to translate into non-English languages, contains a lot of error checking routines, and uses the GNU command-line parameter system, the source code is a good deal more complex than the average “Hello!” you’d find in a programming book. Nothing wrong with that, though; it just makes it more educational!
Several Linux distributions (notably Debian, Debian’s spurious spawn, and OpenSuSE) contain hello in their package repositories, borrowing GNU’s idea and using it as an example of how to package one of their packages. If you are one of the lucky users of one of these, you can install hello with a couple of clicks, using your distro’s package manager. For the rest, there’s compiling from source. But wait! For those of you who’ve never done such a thing before, let me tell you - in this case, at least, compiling is very easy. Remember, this is a very simple program, specially designed to be the ideal GNU package. Actually, I recommend compiling hello from source to everyone; because this way, you get to look at the source code!
If you’ve never compiled anything from source before, you may not have everything you need to do so, installed. For users of Debian derivatives (like me), check to make sure you have a package called build-essential installed. If you don’t, do. It automatically installs the other packages you need to build stuff - gcc, g++, make, libc6-dev, etc. So, if you don’t run a member of the Debian family, make sure you have all that stuff installed, instead. Then . . . to work!
All you have to do is run three commands, in the directory you extracted the code into: ./configure, make, and sudo make install. The last one requires you to enter your root password, as well, since it copies files into your /usr/local directory. Wait for them each to finish, and then - you can greet the world!
To run the program, type hello at your shell prompt, and press ‘Enter’. Your computer will display a cheery message to the world at large, and bring you back to the prompt. But that’s not all there is to it! There are command-line parameters! hello -v will give you hello’s version information. A -h after the program name will tell you how to use it, and what all the parameters are. To salute the globe the olden way, the way the The C Programming Language says to do it, add a -t to the command-line; and a -n will surround your message with a pretty ASCII border.
And, you can even write your own custom greetings! hello --greeting="Howdy" will print Howdy on the screen. There are a few rather . . . interesting restrictions on what you can do with this, though. If your message contains multiple words, you must enclose them with quotes, or the program will think the second word is an extra parameter, and puke. And, if you use quotes, you cannot put an exclamation mark at the end of your message. Nor can you use more than one exclamation mark in a row, or, for that matter, have any character at all after an exclamation mark, except a space. This is not a bug in hello, though: it is a feature of the bash shell. Really.
Not that it matters, though. After all, who’d really care to type out extensive messages, only to have the computer spit them right back at you? (Besides me.) But that’s what hello exists for, as far as the non-programmer is concerned — giving you a few minutes of mild amusement. And it was fun, wasn’t it?
And that’s all, folks. This review is now, I think, longer than the source code of the program reviewed! But I enjoyed writing it, and I hope you liked reading it, too. So here’s to the many applications to come, of all types and sizes! The programs, may they be interesting; and the reviews, may they be fun!
Good night!