help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Help to add new builtin


From: Greg Wooledge
Subject: Re: [Help-bash] Help to add new builtin
Date: Thu, 8 Aug 2019 09:22:13 -0400
User-agent: Mutt/1.10.1 (2018-07-13)

On Thu, Aug 08, 2019 at 10:09:33AM -0300, Joaquin Manuel Crespo wrote:
> Thank you a lot for the tip.
> One question, since "enable" load the program as a builtin into bash
> (excluding that in builtin the same is executed in the same ram space as
> the shell and by the shell) in this case, What is the advantage of use
> "enable" instead of execute the program in another child PID putting the
> program in the "PATH" variable? Regardless the minimal difference of speed.

In addition to the speed boost, builtins have access to your variables
(both reading and writing), they can change your working directory,
they can open or close file descriptors, etc.  All of these changes
would affect the current shell process, rather than being isolated in
a child process.

> I would like integrate my programs directly into the source code, instead
> of storage in another folder the programs or/and put the "enable" builtin
> in "/etc/bash.bashrc"

OK, in that case, pick one of the existing bash builtins to use as a
model, and make your new builtin do the same things that the old one
does.



reply via email to

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