1 /* This module should be dynamically loaded with enable -f
2 * which would create a new builtin named mypid. You'll need
3 * the source code for GNU bash to recompile this module.
5 * Then, from within bash, enable -f ./mypid enable_mypid, where ./mypid
6 * is the binary obtained from running make. Hereafter, `${MYPID}'
7 * is a shell builtin variable.
17 #define INIT_DYNAMIC_VAR(var, val, gfunc, afunc) \
19 { SHELL_VAR *v = bind_variable (var, (val), 0); \
20 v->dynamic_value = gfunc; \
21 v->assign_func = afunc; \
36 get_mypid (SHELL_VAR *var)
44 FREE (value_cell (var));
46 VSETATTR (var, att_integer);
47 var_setvalue (var, p);
52 enable_mypid_builtin(WORD_LIST *list)
54 INIT_DYNAMIC_VAR ("MYPID", (char *)NULL, get_mypid, assign_mypid);
59 char const *enable_mypid_doc[] = {
62 "Enables use of the ${MYPID} dynamic variable. ",
63 "It will yield the current pid of a subshell.",
67 struct builtin enable_mypid_struct = {
71 (char**)(void*)enable_mypid_doc,