Problem executing builtin with find

Problem executing builtin with find

am 17.01.2008 23:48:12 von fvulto

Problem executing builtin with find

I want to use find to execute a bash builtin (complete), but I'm
having problems executing a builtin with the -exec option. Eval
yields the same error:

$> find . -maxdepth 0 -name '*' -execdir complete -F foo {} \+
find: complete: No such file or directory
$> find . -maxdepth 0 -name '*' -execdir eval complete -F foo {} \+
find: eval: No such file or directory

Right now I'm using 'complete -F foo $(ls)' but since this might
exceed the maximum command line length I would like to use find. Is
this possible?

Thanks in advance,

Freddy Vulto

Re: Problem executing builtin with find

am 18.01.2008 03:55:59 von Icarus Sparry

On Thu, 17 Jan 2008 14:48:12 -0800, fred71 wrote:

> Problem executing builtin with find
>
> I want to use find to execute a bash builtin (complete), but I'm having
> problems executing a builtin with the -exec option. Eval yields the
> same error:
>
> $> find . -maxdepth 0 -name '*' -execdir complete -F foo {} \+ find:
> complete: No such file or directory $> find . -maxdepth 0 -name '*'
> -execdir eval complete -F foo {} \+ find: eval: No such file or
> directory
>
> Right now I'm using 'complete -F foo $(ls)' but since this might exceed
> the maximum command line length I would like to use find. Is this
> possible?
>
> Thanks in advance,
>
> Freddy Vulto

Yuk!
It is good that you are worried about length limits. However if you are
exceeding them in a single directory then you will probably be having
lots of problems, and not having a completion function around will
probably be the least of them.

Is there a good reason why you are not doing
complete -F foo *
which will cause bash to produce the list internally, rather than needing
an external program and hence hit limits. If bash has not got enough
memory to expand the * itself, I doubt it has enough memory to store them
and a function to expand them.

Re: Problem executing builtin with find

am 18.01.2008 11:08:43 von Stephane CHAZELAS

On Thu, 17 Jan 2008 14:48:12 -0800 (PST), fred71 wrote:
> Problem executing builtin with find
>
> I want to use find to execute a bash builtin (complete), but I'm
> having problems executing a builtin with the -exec option. Eval
> yields the same error:
>
> $> find . -maxdepth 0 -name '*' -execdir complete -F foo {} \+
> find: complete: No such file or directory
> $> find . -maxdepth 0 -name '*' -execdir eval complete -F foo {} \+
> find: eval: No such file or directory

You said yourself that they were builtin. If they are built in a
shell, then you need to have find execute a shell.

Of course that wouldn't do, as what you want if for that
complete to be executed by the current shell.

> Right now I'm using 'complete -F foo $(ls)' but since this might
> exceed the maximum command line length I would like to use find. Is
> this possible?
[...]

The limitation is on the execve(2) system call, so when
executing external commands, not builtins.

$(ls) is definitely wrong. Use globbing instead.

-maxdepth 0 will only report "." (note that -maxdepth is a
GNU/FreeBSD extension so is -execdir)

-name '*' is a noop. Every filename matches '*'!

+ is a not special in any shell, so you don't need to escape it.

--
Stephane