stat: Fix return value when one of stats fails

This commit is contained in:
Bananymous 2025-05-13 10:15:24 +03:00
parent 0661b339a0
commit e7f0cd0c4b
1 changed files with 5 additions and 0 deletions

View File

@ -16,12 +16,15 @@ void print_timestamp(timespec ts)
int main(int argc, char** argv)
{
int ret = 0;
for (int i = 1; i < argc; i++)
{
struct stat st;
if (stat(argv[i], &st) == -1)
{
perror("stat");
ret = 1;
continue;
}
@ -72,4 +75,6 @@ int main(int argc, char** argv)
printf("Modify: "); print_timestamp(st.st_mtim); printf("\n");
printf("Change: "); print_timestamp(st.st_ctim); printf("\n");
}
return ret;
}