coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to check for dirent.d_type support from shell, python or perl?


From: Pádraig Brady
Subject: Re: how to check for dirent.d_type support from shell, python or perl?
Date: Fri, 13 May 2011 13:18:28 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3

On 13/05/11 13:06, Jim Meyering wrote:
> Very nice.  Thank you!
> That appears to work fine on Linux/glibc,
> but fails on a solaris 10 system which lacks ctypes:
> 
> and fails on solaris 5.11 and freebsd 8.x due to the absence of libc.so.6
> (one of those has libc.so and libc.so.1):

Yep, you'll need this around the whole script:

try:
  # the script
except:
  sys.exit(1)

If we were paranoid about segfaults which I've seen
happen with ctypes, one might wrap the script in (unlimit -c 0; )

> requiring that "." be the first entry
> should be enough for nearly all uses.
> 
>   sys.exit(ep.contents.d_name != "." or ep.contents.d_type != DT_DIR)

Yep that should give enough test coverage,
and we can just comment in the script for cases where it fails.

cheers,
Pádraig.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]