Use warn() instead of perror() or fprintf() where appropriate.
This commit is contained in:
parent
364bf7afb2
commit
e09fdabddf
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=106479
12
bin/ls/ls.c
12
bin/ls/ls.c
@ -330,7 +330,7 @@ main(int argc, char *argv[])
|
||||
f_color = 1;
|
||||
}
|
||||
#else
|
||||
(void)fprintf(stderr, "Color support not compiled in.\n");
|
||||
warnx("color support not compiled in");
|
||||
#endif /*COLORLS*/
|
||||
|
||||
#ifdef COLORLS
|
||||
@ -691,9 +691,7 @@ display(FTSENT *p, FTSENT *list, int options)
|
||||
|
||||
error = mac_prepare_file_label(&label);
|
||||
if (error == -1) {
|
||||
fprintf(stderr, "%s: %s\n",
|
||||
cur->fts_name,
|
||||
strerror(errno));
|
||||
warn("%s", cur->fts_name);
|
||||
goto label_out;
|
||||
}
|
||||
|
||||
@ -712,7 +710,7 @@ display(FTSENT *p, FTSENT *list, int options)
|
||||
error = mac_get_link(name,
|
||||
label);
|
||||
if (error == -1) {
|
||||
perror(cur->fts_name);
|
||||
warn("%s", cur->fts_name);
|
||||
mac_free(label);
|
||||
goto label_out;
|
||||
}
|
||||
@ -720,9 +718,7 @@ display(FTSENT *p, FTSENT *list, int options)
|
||||
error = mac_to_text(label,
|
||||
&labelstr);
|
||||
if (error == -1) {
|
||||
fprintf(stderr, "%s: %s\n",
|
||||
cur->fts_name,
|
||||
strerror(errno));
|
||||
warn("%s", cur->fts_name);
|
||||
mac_free(label);
|
||||
goto label_out;
|
||||
}
|
||||
|
@ -558,10 +558,9 @@ parsecolors(const char *cs)
|
||||
if (c[j] >= '0' && c[j] <= '7') {
|
||||
colors[i].num[j] = c[j] - '0';
|
||||
if (!legacy_warn) {
|
||||
fprintf(stderr,
|
||||
"warn: LSCOLORS should use "
|
||||
warnx("LSCOLORS should use "
|
||||
"characters a-h instead of 0-9 ("
|
||||
"see the manual page)\n");
|
||||
"see the manual page)");
|
||||
}
|
||||
legacy_warn = 1;
|
||||
} else if (c[j] >= 'a' && c[j] <= 'h')
|
||||
@ -572,9 +571,8 @@ parsecolors(const char *cs)
|
||||
} else if (tolower((unsigned char)c[j] == 'x'))
|
||||
colors[i].num[j] = -1;
|
||||
else {
|
||||
fprintf(stderr,
|
||||
"error: invalid character '%c' in LSCOLORS"
|
||||
" env var\n", c[j]);
|
||||
warnx("invalid character '%c' in LSCOLORS"
|
||||
" env var", c[j]);
|
||||
colors[i].num[j] = -1;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user