projects
/
dus.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
6682914
)
Keep the stderr messages on file access errors even with the -i option.
author
Francois Fleuret
<francois@fleuret.org>
Mon, 18 Apr 2011 06:25:08 +0000
(08:25 +0200)
committer
Francois Fleuret
<francois@fleuret.org>
Mon, 18 Apr 2011 06:25:08 +0000
(08:25 +0200)
dus.1
patch
|
blob
|
history
dus.c
patch
|
blob
|
history
diff --git
a/dus.1
b/dus.1
index
e791861
..
01b5cc1
100644
(file)
--- a/
dus.1
+++ b/
dus.1
@@
-33,7
+33,7
@@
print the version number and exit
ignore files and directories whose name starts with a dot
.TP
\fB-i\fR, \fB--ignore-protected\fR
ignore files and directories whose name starts with a dot
.TP
\fB-i\fR, \fB--ignore-protected\fR
-
ignore
files and directories for which we do not have permission
+
do not exit when trying to access
files and directories for which we do not have permission
.TP
\fB-f\fR, \fB--fancy\fR
display floating point size with K, M and G units
.TP
\fB-f\fR, \fB--fancy\fR
display floating point size with K, M and G units
diff --git
a/dus.c
b/dus.c
index
a7e3908
..
6de022a
100644
(file)
--- a/
dus.c
+++ b/
dus.c
@@
-66,9
+66,9
@@
size_sum_t size_min = -1; /* -1 means no minimum size, otherwise lower
bound on the size to display a
file/dir */
bound on the size to display a
file/dir */
-int
ignore_protected_files = 0; /* Should we simply ignore files or
- directories which are protected
- ? */
+int
dont_exit_on_protected_files = 0; /* Should we go on when we meet
+ files or directories which
+
are protected
? */
/********************************************************************/
/********************************************************************/
@@
-105,10
+105,10
@@
size_sum_t entry_size(const char *name, int *isdir) {
if(isdir) { *isdir = 0; }
if(lstat(name, &dummy) != 0) {
if(isdir) { *isdir = 0; }
if(lstat(name, &dummy) != 0) {
- if(!(errno == EACCES && ignore_protected_files)) {
-
fprintf(stderr
,
- "dus: Can not stat %s: %s\n",
- name, strerror(errno));
+ fprintf(stderr,
+
"dus: Can not stat %s: %s\n"
,
+ name, strerror(errno));
+ if(!(errno == EACCES && dont_exit_on_protected_files)) {
exit(EXIT_FAILURE);
} else {
return 0;
exit(EXIT_FAILURE);
} else {
return 0;
@@
-131,10
+131,10
@@
size_sum_t entry_size(const char *name, int *isdir) {
}
closedir(dir);
} else {
}
closedir(dir);
} else {
- if(!(errno == EACCES && ignore_protected_files)) {
-
fprintf(stderr
,
- "dus: Can not open directory %s: %s\n",
- name, strerror(errno));
+ fprintf(stderr,
+
"dus: Can not open directory %s: %s\n"
,
+ name, strerror(errno));
+ if(!(errno == EACCES && dont_exit_on_protected_files)) {
exit(EXIT_FAILURE);
}
}
exit(EXIT_FAILURE);
}
}
@@
-404,8
+404,8
@@
void usage(FILE *out) {
fprintf(out, " -h, --help show this help.\n");
fprintf(out, " -v, --version prints the version number and exit\n");
fprintf(out, " -d, --ignore-dots ignore files and directories starting with a '.'\n");
fprintf(out, " -h, --help show this help.\n");
fprintf(out, " -v, --version prints the version number and exit\n");
fprintf(out, " -d, --ignore-dots ignore files and directories starting with a '.'\n");
- fprintf(out, " -i, --ignore-protected
ignore files and directories for which we do not
\n");
- fprintf(out, " have permission\n");
+ fprintf(out, " -i, --ignore-protected
do not exit when visiting files and directories
\n");
+ fprintf(out, "
for which we do not
have permission\n");
fprintf(out, " -f, --fancy display size with float values and K, M and G\n");
fprintf(out, " units.\n");
fprintf(out, " -r, --reverse-order reverse the sorting order.\n");
fprintf(out, " -f, --fancy display size with float values and K, M and G\n");
fprintf(out, " units.\n");
fprintf(out, " -r, --reverse-order reverse the sorting order.\n");
@@
-463,7
+463,7
@@
int main(int argc, char **argv) {
break;
case 'i':
break;
case 'i':
-
ignore
_protected_files = 1;
+
dont_exit_on
_protected_files = 1;
break;
case 'f':
break;
case 'f':