Jim Meyering wrote: > Pádraig Brady wrote: >> Perhaps we should change ls to also print the 0 if the stat succeeds? > > Do you think that'd be worthwhile? > I wouldn't want to update the documentation to explain under > which conditions you might see a "0" rather than "?" ;-)
Well it would allow one to distinguish between a failure and the system returning 0 for st_ino. Also it would be more consistent with stat(1). But you're right that the gain is marginal, especially if st_ino==0 is deemed invalid, which POSIX seems to suggest. >> That means we can distinguish between a failure (?) and the OS >> returning 0 as a "valid" number. >> Also, even if we do that, in the test we would need to skip the case >> where `stat` returns nothing on error. > > As suggested, this should do the trick: > > stat_inode=$(env stat --format=%i $dir) > + # If stat fails or says the inode is 0, skip $dir. > + case $stat_inode in 0|'') continue;; esac > test "$readdir_inode" = "$stat_inode" || fail=1 Looks good. cheers, Pádraig.
