If we're going to get really picky on coding style in a Unix Enthusiasts mailing list, keep your lines to 80 characters in length. You have a few that go over considering your 8 space tabs.
Background: http://richarddingwall.name/2008/05/31/is-the-80-character-line-limit-still-relevant/ And since you are certainly using vim and not an inferior editor, you can switch your tab settings and make editing a bit nicer with a few of the following settings in your .vimrc file: set expandtab [inserts spaces instead of tabs] set shiftwidth=3 [changes the number of spaces for indentation] set tabstop=3 [tells vim how many spaces count for a tab] -- Brett Johnson simpleroute | 1690 Williston Road | South Burlington, VT 05401 tel: 802-578-3983 | email: [email protected] | web: simpleroute.com On Mon, Sep 20, 2010 at 7:05 PM, Josh Sled <[email protected]> wrote: > David McClellan <[email protected]> writes: >> printf("Why does this directory not work???: %s\n",argv[2]); >> while(entry = readdir(currentDirectory)) { > > BTW, if you want to write this as a while loop, I encourage you to write > this as: > > while ((entry = readdir(currentDirectory)) != NULL) { > > Style points as follows: > > 1/ "while" is a keyword, not a function name, and thus has a space after > it (similarly "if", "for", &c.). > > 1b/ Consistency! > > if (stat(entry->d_name, &statbuf == -1) > ^ > > if ((pwd = gwetpwuid(statbuf.st_uid)) != NULL) > ^ ^ > > 2/ Eschew the implicit boolean. You are not testing that readdir > happens to return a value that happens to be considered equal to "false" > … you're testing the boolean condition that readdir returns a value not > equal to NULL. So write that. Some might call it splitting hairs, but > the latter is closer to what you actually mean. > > 3/ Many people go further and say that one should never use the > side-effect of an assignment (value return). I disagree. But note that > many people do say this, as many find it confusing. Caveat writer. > > 4/ Tabs are always spaces … but 8 spaces is a bit excessive. ;) > > -- > ...jsled > http://asynchronous.org/ - a=jsled; b=asynchronous.org; echo $...@${b} >
