Home | History | Annotate | Download | only in make

Lines Matching defs:Shell

88  *	Job_ParseShell	Given a special dependency line with target '.SHELL',
89 * define the shell that is used for the creation
169 * A Job manages the shell commands that are run to create a single target.
170 * Each job is run in a separate subprocess by a shell. Several jobs can run
173 * The shell commands for the target are written to a temporary file,
174 * then the shell is run with the temporary file as stdin, and the output
175 * of that shell is captured via a pipe.
182 /* The process ID of the shell running the commands */
189 * If one of the shell commands is "...", all following commands are
195 /* This is where the shell commands go. */
227 * A shell defines how the commands are run. All commands for a target are
228 * written into a single file, which is then given to the shell to execute
232 * The name of the shell is the basename for the predefined shells, such as
234 * basename is used to select the type of shell; the longest match wins.
238 * echoOn, noPrint and noPrintLen. When echoOff is executed by the shell, it
245 * In case a shell doesn't have error control, echoTmpl is a printf template
249 * causing the shell to exit on error. If any of these strings are empty when
253 * shell code injection, the escaped command is safe to use in double quotes.
256 * "echo" flag causes the shell to start echoing commands right away. The
257 * "exit" flag causes the shell to exit when an error is detected in one of
260 typedef struct Shell {
263 * The name of the shell. For Bourne and C shells, this is used only
264 * to find the shell description when used as the single source of a
265 * .SHELL target. For user-defined shells, this is the full path of
266 * the shell.
274 * shell. This is usually the same as echoOff */
293 char commentChar; /* character used by shell for comment lines */
295 const char *echoFlag; /* shell flag to echo commands */
296 const char *errFlag; /* shell flag to exit on error */
297 } Shell;
314 * Write shell commands to a file.
347 * select one of the predefined shells as the default shell.
350 * name or the full path of a sh-compatible shell, which will be used as
351 * the default shell.
353 * ".SHELL" lines in Makefiles can choose the default shell from the
372 static Shell shells[] = {
375 * An sh-compatible shell with a non-standard name.
450 * with the setting of the 'echo' shell variable. Sadly,
474 * This is the shell to which we pass all commands in the Makefile.
477 static Shell *shell = &shells[DEFSHELL_INDEX];
481 static char *shell_freeIt = NULL; /* Allocated memory for custom .SHELL */
868 if (shell->hasEchoCtl)
869 ShellWriter_WriteLine(wr, shell->echoOff);
875 ShellWriter_WriteFmt(wr, shell->echoTmpl, escCmd);
881 if (shell->hasEchoCtl)
882 ShellWriter_WriteLine(wr, shell->echoOn);
899 ShellWriter_WriteLine(wr, shell->errOff);
909 ShellWriter_WriteLine(wr, shell->errOn);
915 * The shell has no built-in error control, so emulate error control by
916 * enclosing each shell command in a template like "{ %s \n } || exit $?"
917 * (configurable per shell).
936 *inout_cmdTemplate = shell->runIgnTmpl;
952 else if (shell->hasErrCtl)
954 else if (shell->runIgnTmpl != NULL && shell->runIgnTmpl[0] != '\0') {
962 * Write a shell command to the job's commands file, to be run later.
965 * given to make, stick a shell-specific echoOff command in the script.
967 * If the command starts with '-' and the shell has no error control (none
982 /* Template for writing a command to the shell file */
1010 * If the shell doesn't have error control, the alternate echoing
1014 escCmd = shell->hasErrCtl ? NULL : EscapeShellDblQuot(xcmd);
1017 if (job->echo && run && shell->hasEchoCtl)
1019 else if (shell->hasErrCtl)
1028 * If errors are being checked and the shell doesn't have
1033 if (!shell->hasErrCtl && shell->runChkTmpl != NULL &&
1034 shell->runChkTmpl[0] != '\0') {
1044 cmdTemplate = escCmd[0] == shell->commentChar ||
1046 ? shell->runIgnTmpl
1047 : shell->runChkTmpl;
1052 if (DEBUG(SHELL) && strcmp(shellName, "sh") == 0)
1067 * Write all commands to the shell file that is later executed.
1072 * Return whether at least one command was written to the shell file.
1244 Punt("Cannot write shell script for \"%s\": %s",
1465 * Execute the shell for the given job.
1467 * See Job_CatchOutput for handling the output of the shell.
1548 * to clear it before routing the shell's error output to
1591 Punt("Cannot write shell script for \"%s\": %s",
1614 if ((shell->errFlag != NULL && shell->errFlag[0] != '-') ||
1615 (shell->echoFlag != NULL && shell->echoFlag[0] != '-')) {
1619 * shell thinks its second argument is a file to source.
1627 !job->ignerr && shell->errFlag != NULL
1628 ? shell->errFlag : "",
1629 job->echo && shell->echoFlag != NULL
1630 ? shell->echoFlag : "");
1636 if (!job->ignerr && shell->errFlag != NULL) {
1637 argv[argc] = UNCONST(shell->errFlag);
1640 if (job->echo && shell->echoFlag != NULL) {
1641 argv[argc] = UNCONST(shell->echoFlag);
1763 * If the shell has an output filter (which only csh and ksh have by default),
1765 * shell.
1775 if (shell->noPrint == NULL || shell->noPrint[0] == '\0')
1779 while ((ep = strstr(p, shell->noPrint)) != NULL && ep < endp) {
1786 p = ep + shell->noPrintLen;
1798 * In the output of the shell, the 'noPrint' lines are removed. If the
2036 shellName = shell->name;
2055 Var_SetWithFlags(SCOPE_CMDLINE, ".SHELL", shellPath,
2057 if (shell->errFlag == NULL)
2058 shell->errFlag = "";
2059 if (shell->echoFlag == NULL)
2060 shell->echoFlag = "";
2061 if (shell->hasErrCtl && shell->errFlag[0] != '\0') {
2063 strcmp(shell->errFlag, &shellErrFlag[1]) != 0) {
2068 shellErrFlag = str_concat2("-", shell->errFlag);
2075 /* Return the shell string literal that results in a newline character. */
2079 return shell->newline;
2198 static Shell *
2201 Shell *sh = shells;
2202 const Shell *shellsEnd = sh + sizeof shells / sizeof shells[0];
2212 * Parse a shell specification and set up 'shell', shellPath and
2216 * line The shell spec
2220 * If successful, 'shell' is usable, shellPath is the full path of the
2221 * shell described by 'shell', and shellName is the final component of
2225 * A shell specification has the form ".SHELL: keyword=value...". Double
2230 * name Name of shell.
2231 * path Location of shell.
2234 * filter The output from the shell command that turns off
2238 * hasErrCtl True if the shell has error checking control.
2242 * shell command that echoes a command for which error
2246 * shell command that executes a command so as to ignore
2257 Shell newShell;
2259 Shell *sh;
2339 "%s: No matching shell", newShell.name);
2343 shell = sh;
2359 "%s: No matching shell", shellName);
2363 shell = sh;
2365 shell = bmake_malloc(sizeof *shell);
2366 *shell = newShell;
2372 if (shell->echoOn != NULL && shell->echoOff != NULL)
2373 shell->hasEchoCtl = true;
2375 if (!shell->hasErrCtl) {
2376 if (shell->echoTmpl == NULL)
2377 shell->echoTmpl = "";
2378 if (shell->runIgnTmpl == NULL)
2379 shell->runIgnTmpl = "%s\n";
2384 * by the shell specification.