Or how to create new builtins for use in
bash. Short answer: you can,
but it is not enabled by default (at least on my distribution, Ubuntu)
This is also something that is done much better in
Why do want this? SPEED!
Shell scripting is a very easy way to program, but forking all these helper programs takes a lot of time. So one way to speed up your shell program is to load these programs into the shell and making them a builtin.
I needed the bash source for this to work. So download it and
compile it. Then in the
examples/loadables you have some
new builtins, like
head and then some.
cat a builtin, you need the
$ type cat cat is /bin/cat $ enable -f /tmp/bash-3.2/examples/loadables/cat cat $ cat type cat is a shell builtin
Same goes for other executables. When updating my site with
cat and others as builtins made the
update much quicker. I shaved off some 20 seconds on a total
of 250 seconds; so it may be worth the effort.
Here everything worked out of the box, but there is currently
cat builtin for zsh (I created one). But there are
other interesting builtins.
What you need:
man zshmodules and
zmodload. With zmodload
you can create new builtins.
For example, I made a
cat builtin. Next I copy the
% type cat cat is /bin/cat % zmodload zsh/cat % type cat cat is a shell builtin
zmodload -u. Works like a charm.