Re: [hackers] [sbase][PATCH] ls: abort a directory if we cannot opendir it

From: Quentin Rameau <quinq_AT_fifth.space>
Date: Tue, 22 Aug 2017 10:08:48 +0200

Hello David,

> We should not try and perform operations on an invalid DIR* stream.
> Instead, we shall let the error message be printed, and the return
> code set (existing behaviour) and abort afterwards.

Any justification you could provide us with?

AFAIK POSIX specifies the opposite, a diognostic message should be
issued on stderr and the utility should continue processing the
remaining of the operands/hierarchy.

> ---
> ls.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/ls.c b/ls.c
> index 5080c8f..b716aba 100644
> --- a/ls.c
> +++ b/ls.c
> _AT_@ -250,6 +250,7 @@ lsdir(const char *path, const struct entry *dir)
> if (!(dp = opendir(dir->name))) {
> ret = 1;
> weprintf("opendir %s%s:", path, dir->name);
> + return;
> }
> if (chdir(dir->name) < 0)
> eprintf("chdir %s:", dir->name);
Received on Tue Aug 22 2017 - 10:08:48 CEST

This archive was generated by hypermail 2.3.0 : Tue Aug 22 2017 - 10:12:24 CEST