Lines Matching full:shell
88 * Job_ParseShell Given a special dependency line with target '.SHELL',
89 * define the shell that is used for the creation
182 * A Job manages the shell commands that are run to create a single target.
183 * Each job is run in a separate subprocess by a shell. Several jobs can run
186 * The shell commands for the target are written to a temporary file,
187 * then the shell is run with the temporary file as stdin, and the output
188 * of that shell is captured via a pipe.
195 /* The process ID of the shell running the commands */
202 * If one of the shell commands is "...", all following commands are
208 /* This is where the shell commands go. */
240 * A shell defines how the commands are run. All commands for a target are
241 * written into a single file, which is then given to the shell to execute
245 * The name of the shell is the basename for the predefined shells, such as
247 * basename is used to select the type of shell; the longest match wins.
251 * echoOn, noPrint and noPrintLen. When echoOff is executed by the shell, it
258 * In case a shell doesn't have error control, echoTmpl is a printf template
262 * causing the shell to exit on error. If any of these strings are empty when
266 * shell code injection, the escaped command is safe to use in double quotes.
269 * "echo" flag causes the shell to start echoing commands right away. The
270 * "exit" flag causes the shell to exit when an error is detected in one of
273 typedef struct Shell { struct
276 * The name of the shell. For Bourne and C shells, this is used only
277 * to find the shell description when used as the single source of a
278 * .SHELL target. For user-defined shells, this is the full path of
279 * the shell.
287 * shell. This is usually the same as echoOff */
306 char commentChar; /* character used by shell for comment lines */
308 const char *echoFlag; /* shell flag to echo commands */
309 const char *errFlag; /* shell flag to exit on error */
310 } Shell; argument
327 * Write shell commands to a file.
376 * select one of the predefined shells as the default shell.
379 * name or the full path of a sh-compatible shell, which will be used as
380 * the default shell.
382 * ".SHELL" lines in Makefiles can choose the default shell from the
401 static Shell shells[] = {
404 * An sh-compatible shell with a non-standard name.
479 * with the setting of the 'echo' shell variable. Sadly,
503 * This is the shell to which we pass all commands in the Makefile.
506 static Shell *shell = &shells[DEFSHELL_INDEX]; variable
510 static char *shell_freeIt = NULL; /* Allocated memory for custom .SHELL */
897 if (shell->hasEchoCtl) in ShellWriter_EchoOff()
898 ShellWriter_WriteLine(wr, shell->echoOff); in ShellWriter_EchoOff()
904 ShellWriter_WriteFmt(wr, shell->echoTmpl, escCmd); in ShellWriter_EchoCmd()
910 if (shell->hasEchoCtl) in ShellWriter_EchoOn()
911 ShellWriter_WriteLine(wr, shell->echoOn); in ShellWriter_EchoOn()
928 ShellWriter_WriteLine(wr, shell->errOff); in ShellWriter_ErrOff()
938 ShellWriter_WriteLine(wr, shell->errOn); in ShellWriter_ErrOn()
944 * The shell has no built-in error control, so emulate error control by
945 * enclosing each shell command in a template like "{ %s \n } || exit $?"
946 * (configurable per shell).
965 *inout_cmdTemplate = shell->runIgnTmpl; in JobWriteSpecialsEchoCtl()
981 else if (shell->hasErrCtl) in JobWriteSpecials()
983 else if (shell->runIgnTmpl != NULL && shell->runIgnTmpl[0] != '\0') { in JobWriteSpecials()
991 * Write a shell command to the job's commands file, to be run later.
994 * given to make, stick a shell-specific echoOff command in the script.
996 * If the command starts with '-' and the shell has no error control (none
1011 /* Template for writing a command to the shell file */ in JobWriteCommand()
1039 * If the shell doesn't have error control, the alternate echoing in JobWriteCommand()
1043 escCmd = shell->hasErrCtl ? NULL : EscapeShellDblQuot(xcmd); in JobWriteCommand()
1046 if (job->echo && run && shell->hasEchoCtl) in JobWriteCommand()
1048 else if (shell->hasErrCtl) in JobWriteCommand()
1057 * If errors are being checked and the shell doesn't have in JobWriteCommand()
1062 if (!shell->hasErrCtl && shell->runChkTmpl != NULL && in JobWriteCommand()
1063 shell->runChkTmpl[0] != '\0') { in JobWriteCommand()
1073 cmdTemplate = escCmd[0] == shell->commentChar || in JobWriteCommand()
1075 ? shell->runIgnTmpl in JobWriteCommand()
1076 : shell->runChkTmpl; in JobWriteCommand()
1081 if (DEBUG(SHELL) && strcmp(shellName, "sh") == 0) in JobWriteCommand()
1096 * Write all commands to the shell file that is later executed.
1101 * Return whether at least one command was written to the shell file.
1273 Punt("Cannot write shell script for \"%s\": %s", in JobFinish()
1494 * Execute the shell for the given job.
1496 * See Job_CatchOutput for handling the output of the shell.
1578 * to clear it before routing the shell's error output to in JobExec()
1623 Punt("Cannot write shell script for \"%s\": %s", in JobExec()
1646 if ((shell->errFlag != NULL && shell->errFlag[0] != '-') || in BuildArgv()
1647 (shell->echoFlag != NULL && shell->echoFlag[0] != '-')) { in BuildArgv()
1651 * shell thinks its second argument is a file to source. in BuildArgv()
1659 !job->ignerr && shell->errFlag != NULL in BuildArgv()
1660 ? shell->errFlag : "", in BuildArgv()
1661 job->echo && shell->echoFlag != NULL in BuildArgv()
1662 ? shell->echoFlag : ""); in BuildArgv()
1668 if (!job->ignerr && shell->errFlag != NULL) { in BuildArgv()
1669 argv[argc] = UNCONST(shell->errFlag); in BuildArgv()
1672 if (job->echo && shell->echoFlag != NULL) { in BuildArgv()
1673 argv[argc] = UNCONST(shell->echoFlag); in BuildArgv()
1795 * If the shell has an output filter (which only csh and ksh have by default),
1797 * shell.
1807 if (shell->noPrint == NULL || shell->noPrint[0] == '\0') in PrintFilteredOutput()
1811 while ((ep = strstr(p, shell->noPrint)) != NULL && ep < endp) { in PrintFilteredOutput()
1818 p = ep + shell->noPrintLen; in PrintFilteredOutput()
1830 * In the output of the shell, the 'noPrint' lines are removed. If the
2068 shellName = shell->name; in InitShellNameAndPath()
2090 Var_SetWithFlags(SCOPE_CMDLINE, ".SHELL", shellPath, in Shell_Init()
2092 if (shell->errFlag == NULL) in Shell_Init()
2093 shell->errFlag = ""; in Shell_Init()
2094 if (shell->echoFlag == NULL) in Shell_Init()
2095 shell->echoFlag = ""; in Shell_Init()
2096 if (shell->hasErrCtl && shell->errFlag[0] != '\0') { in Shell_Init()
2098 strcmp(shell->errFlag, &shellErrFlag[1]) != 0) { in Shell_Init()
2103 shellErrFlag = str_concat2("-", shell->errFlag); in Shell_Init()
2110 /* Return the shell string literal that results in a newline character. */
2114 return shell->newline; in Shell_GetNewline()
2241 static Shell *
2244 Shell *sh = shells; in FindShellByName()
2245 const Shell *shellsEnd = sh + sizeof shells / sizeof shells[0]; in FindShellByName()
2255 * Parse a shell specification and set up 'shell', shellPath and
2259 * line The shell spec
2263 * If successful, 'shell' is usable, shellPath is the full path of the
2264 * shell described by 'shell', and shellName is the final component of
2268 * A shell specification has the form ".SHELL: keyword=value...". Double
2273 * name Name of shell.
2274 * path Location of shell.
2277 * filter The output from the shell command that turns off
2281 * hasErrCtl True if the shell has error checking control.
2285 * shell command that echoes a command for which error
2289 * shell command that executes a command so as to ignore
2300 Shell newShell; in Job_ParseShell()
2302 Shell *sh; in Job_ParseShell()
2382 "%s: No matching shell", newShell.name); in Job_ParseShell()
2386 shell = sh; in Job_ParseShell()
2402 "%s: No matching shell", shellName); in Job_ParseShell()
2406 shell = sh; in Job_ParseShell()
2408 shell = bmake_malloc(sizeof *shell); in Job_ParseShell()
2409 *shell = newShell; in Job_ParseShell()
2415 if (shell->echoOn != NULL && shell->echoOff != NULL) in Job_ParseShell()
2416 shell->hasEchoCtl = true; in Job_ParseShell()
2418 if (!shell->hasErrCtl) { in Job_ParseShell()
2419 if (shell->echoTmpl == NULL) in Job_ParseShell()
2420 shell->echoTmpl = ""; in Job_ParseShell()
2421 if (shell->runIgnTmpl == NULL) in Job_ParseShell()
2422 shell->runIgnTmpl = "%s\n"; in Job_ParseShell()
2427 * by the shell specification. in Job_ParseShell()