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