[hackers] [dmenu] lsx: return failure on error || Connor Lane Smith

From: <hg_AT_suckless.org>
Date: Sun, 16 Oct 2011 19:16:32 +0200 (CEST)

changeset: 447:23739cb76476
branch: lsx
tag: tip
user: Connor Lane Smith <cls_AT_lubutu.com>
date: Sun Oct 16 18:14:51 2011 +0100
files: lsx.c
description:
lsx: return failure on error


diff -r 0fc73f259fc8 -r 23739cb76476 lsx.c
--- a/lsx.c Sun Oct 16 18:13:29 2011 +0100
+++ b/lsx.c Sun Oct 16 18:14:51 2011 +0100
_AT_@ -8,6 +8,8 @@
 
 static void lsx(const char *dir);
 
+static int status = EXIT_SUCCESS;
+
 int
 main(int argc, char *argv[]) {
         int i;
_AT_@ -16,7 +18,7 @@
                 lsx(".");
         else for(i = 1; i < argc; i++)
                 lsx(argv[i]);
- return EXIT_SUCCESS;
+ return status;
 }
 
 void
_AT_@ -27,12 +29,13 @@
         DIR *dp;
 
         if(!(dp = opendir(dir))) {
+ status = EXIT_FAILURE;
                 perror(dir);
                 return;
         }
         while((d = readdir(dp)))
                 if(snprintf(buf, sizeof buf, "%s/%s", dir, d->d_name) < (int)sizeof buf
- && !stat(buf, &st) && S_ISREG(st.st_mode) && access(buf, X_OK) == 0)
+ && stat(buf, &st) == 0 && S_ISREG(st.st_mode) && access(buf, X_OK) == 0)
                         puts(d->d_name);
         closedir(dp);
 }
Received on Sun Oct 16 2011 - 19:16:32 CEST

This archive was generated by hypermail 2.3.0 : Sun Oct 16 2011 - 19:24:09 CEST