home | list info | list archive | date index | thread index

Re: [OCLUG-Tech] Odd behaviour in find

On Wed, Nov 25, 2015 at 16:52:11 -0500, Alex Pilon wrote:
>     -        find = subprocess.Popen(['find', '--'] + args.args, stdout=subprocess.PIPE)
>     +        find_args = ['-xdev'] if args.X else []
>     +        find = subprocess.Popen(['find'] + find_args + ['--'] + args.args,
>     +                                stdout=subprocess.PIPE)
> 
> I suppose that I could just use a list comprehension but that wouldn't
> be the perfect and simplest way.
 
As I read it the man page suggests something perfectly simple like:

find = subprocess.Popen(
        ['find', '--'] +
            [A if A[0]=='/' else './'+A for A in args.args] +
            (['-xdev'] if args.X else []),
        stdout=subprocess.PIPE)
 
> I just wanted -xdev to be unambiguously an expression, -- treated as the
> options delimiter, and everything after a path.
 
I have to admit I'm not completely clear on what you want, but whatever
it is it needs to be consistent with the documented syntax. You might
want to take another look at the man page.

Joe