22.3.6 Executing a bash process

In the following functions: the file system pathname of bash is preselected and hard–coded in the library at package–configuration time; mbfl_PROGRAM_BASH for details.

Function: mbfl_program_bash ARG

Execute the program bash with the ARG arguments on the command line.

Function: mbfl_program_bash_command COMMAND ARG

Execute COMMAND in a bash subprocess, using the -c switch. If given, the optional ARG arguments are placed on the command line of bash in options position (before the -c option).

mbfl_program_bash_command 'read ; echo "$REPLY"'

Background execution

Notice that if we want to execute bash in background and access its PID with mbfl_program_BGPID we have to use a command like the following (we need the option -i to activate job control):

local THE_PID

mbfl_program_execbg 0 1 "$mbfl_PROGRAM_BASH" '--norc' '--noprofile' '-i' '-c' 'suspend'
THE_PID=$mbfl_program_BGPID

mbfl_process_kill -SIGCONT $THE_PID
mbfl_process_wait $THE_PID

Attempting to use mbfl_program_bash() or mbfl_program_bash_command(), by putting them in the background with &, will not work: it is impossible to determine the executed bash process’ PID from the parent shell process.


This document describes version 3.0.0-devel.9 of Marcos Bash Functions Library.