]> git.ipfire.org Git - thirdparty/bash.git/blame - examples/loadables/README
bash-5.1 distribution sources and documentation
[thirdparty/bash.git] / examples / loadables / README
CommitLineData
ccc6cda3
JA
1Some examples of ready-to-dynamic-load builtins. Most of the
2examples given are reimplementations of standard commands whose
3execution time is dominated by process startup time. The
4exceptions are sleep, which allows you to sleep for fractions
5of a second, finfo, which provides access to the rest of the
6elements of the `stat' structure that `test' doesn't let you
7see, and pushd/popd/dirs, which allows you to compile them out
8of the shell.
9
10All of the new builtins in ksh93 that bash didn't already have
11are included here, as is the ksh `print' builtin.
12
b72432fd
JA
13The configure script in the top-level source directory uses the
14support/shobj-conf script to set the right values in the Makefile,
15so you should not need to change the Makefile. If your system
16is not supported by support/shobj-conf, and it has the necessary
17facilities for building shared objects and support for the
18dlopen/dlsyn/dlclose/dlerror family of functions, please make
19the necessary changes to support/shobj-conf and send the changes
20to bash-maintainers@gnu.org.
ccc6cda3 21
b72432fd 22Loadable builtins are loaded into a running shell with
ccc6cda3 23
b72432fd 24 enable -f filename builtin-name
ccc6cda3
JA
25
26enable uses a simple reference-counting scheme to avoid unloading a
27shared object that implements more than one loadable builtin before
28all loadable builtins implemented in the object are removed.
29
30Many of the details needed by builtin writers are found in hello.c,
31the canonical example. There is no real `builtin writers' programming
b72432fd
JA
32guide'. The file template.c provides a template to use for creating
33new loadable builtins.
0628567a 34
d233b485
CR
35The file "Makefile.inc" is created using the same values that configure
36writes into Makefile.in, and is installed in the same directory as the
37rest of the example builtins. It's intended to be a start at something
38that can be modified or included to help you build your own loadables
39without having to search for the right CFLAGS and LDFLAGS.
40
0628567a
JA
41basename.c Return non-directory portion of pathname.
42cat.c cat(1) replacement with no options - the way cat was intended.
0628567a 43dirname.c Return directory portion of pathname.
8868edaf 44fdflags.c Change the flag associated with one of bash's open file descriptors.
0628567a 45finfo.c Print file info.
0628567a
JA
46head.c Copy first part of files.
47hello.c Obligatory "Hello World" / sample loadable.
48id.c POSIX.2 user identity.
49ln.c Make links.
d233b485 50loadables.h File loadable builtins can include for shell definitions.
0628567a
JA
51logname.c Print login name of current user.
52Makefile.in Simple makefile for the sample loadable builtins.
d233b485 53Makefile.inc.in Sample makefile to use for loadable builtin development.
0628567a 54mkdir.c Make directories.
d233b485 55mypid.c Add $MYPID variable, demonstrate use of unload hook functio.n
0628567a
JA
56necho.c echo without options or argument interpretation.
57pathchk.c Check pathnames for validity and portability.
58print.c Loadable ksh-93 style print builtin.
59printenv.c Minimal builtin clone of BSD printenv(1).
60push.c Anyone remember TOPS-20?
0628567a 61realpath.c Canonicalize pathnames, resolving symlinks.
d233b485 62rm.c Remove files and directories.
0628567a 63rmdir.c Remove directory.
d233b485
CR
64seq.c Print a sequence of decimal or floating point numbers.
65setpgid.c Set a process's pgrp; example of how to wrap a system call.
0628567a 66sleep.c sleep for fractions of a second.
d233b485 67stat.c populate an associative array with information about a file
0628567a
JA
68strftime.c Loadable builtin interface to strftime(3).
69sync.c Sync the disks by forcing pending filesystem writes to complete.
70tee.c Duplicate standard input.
71template.c Example template for loadable builtin.
72truefalse.c True and false builtins.
73tty.c Return terminal name.
74uname.c Print system information.
75unlink.c Remove a directory entry.
76whoami.c Print out username of current user.