Lines Matching refs:shell

102  *			define the shell that is used for the creation
147 * A shell defines how the commands are run. All commands for a target are
148 * written into a single file, which is then given to the shell to execute
152 * The name of the shell is the basename for the predefined shells, such as
154 * basename is used to select the type of shell; the longest match wins.
158 * echoOn, noPrint and noPrintLen. When echoOff is executed by the shell, it
165 * In case a shell doesn't have error control, echoTmpl is a printf template
169 * causing the shell to exit on error. If any of these strings are empty when
173 * shell code injection, the escaped command is safe to use in double quotes.
176 * "echo" flag causes the shell to start echoing commands right away. The
177 * "exit" flag causes the shell to exit when an error is detected in one of
183 * The name of the shell. For Bourne and C shells, this is used only
184 * to find the shell description when used as the single source of a
186 * the shell.
194 * shell. This is usually the same as echoOff */
213 char commentChar; /* character used by shell for comment lines */
215 const char *echoFlag; /* shell flag to echo commands */
216 const char *errFlag; /* shell flag to exit on error */
234 * Write shell commands to a file.
265 * select one of the predefined shells as the default shell.
268 * name or the full path of a sh-compatible shell, which will be used as
269 * the default shell.
271 * ".SHELL" lines in Makefiles can choose the default shell from the
293 * An sh-compatible shell with a non-standard name.
368 * with the setting of the 'echo' shell variable. Sadly,
392 * This is the shell to which we pass all commands in the Makefile.
395 static Shell *shell = &shells[DEFSHELL_INDEX];
770 if (shell->hasEchoCtl)
771 ShellWriter_WriteLine(wr, shell->echoOff);
777 ShellWriter_WriteFmt(wr, shell->echoTmpl, escCmd);
783 if (shell->hasEchoCtl)
784 ShellWriter_WriteLine(wr, shell->echoOn);
801 ShellWriter_WriteLine(wr, shell->errOff);
811 ShellWriter_WriteLine(wr, shell->errOn);
817 * The shell has no built-in error control, so emulate error control by
818 * enclosing each shell command in a template like "{ %s \n } || exit $?"
819 * (configurable per shell).
838 *inout_cmdTemplate = shell->runIgnTmpl;
854 else if (shell->hasErrCtl)
856 else if (shell->runIgnTmpl != NULL && shell->runIgnTmpl[0] != '\0') {
864 * Write a shell command to the job's commands file, to be run later.
867 * given to make, stick a shell-specific echoOff command in the script.
869 * If the command starts with '-' and the shell has no error control (none
888 /* Template for writing a command to the shell file */
916 * If the shell doesn't have error control, the alternate echoing
920 escCmd = shell->hasErrCtl ? NULL : EscapeShellDblQuot(xcmd);
923 if (job->echo && run && shell->hasEchoCtl)
925 else if (shell->hasErrCtl)
934 * If errors are being checked and the shell doesn't have
939 if (!shell->hasErrCtl && shell->runChkTmpl != NULL &&
940 shell->runChkTmpl[0] != '\0') {
950 cmdTemplate = escCmd[0] == shell->commentChar ||
952 ? shell->runIgnTmpl
953 : shell->runChkTmpl;
973 * Write all commands to the shell file that is later executed.
978 * Return whether at least one command was written to the shell file.
1158 Punt("Cannot write shell script for '%s': %s",
1381 * Execute the shell for the given job.
1383 * See Job_CatchOutput for handling the output of the shell.
1474 * to clear it before routing the shell's error output to
1521 Punt("Cannot write shell script for '%s': %s",
1535 /* Create the argv needed to execute the shell for a given job. */
1545 if ((shell->errFlag != NULL && shell->errFlag[0] != '-') ||
1546 (shell->echoFlag != NULL && shell->echoFlag[0] != '-')) {
1550 * shell thinks its second argument is a file to source.
1559 (shell->errFlag != NULL ? shell->errFlag : "")),
1561 (shell->echoFlag != NULL ? shell->echoFlag : "")));
1568 if (!job->ignerr && shell->errFlag != NULL) {
1569 argv[argc] = UNCONST(shell->errFlag);
1572 if (job->echo && shell->echoFlag != NULL) {
1573 argv[argc] = UNCONST(shell->echoFlag);
1584 * tfile is the name of a file into which all shell commands
1585 * are put. It is removed before the child shell is executed,
1614 char *argv[10]; /* Argument vector to shell */
1695 /* If we're not supposed to execute a shell, don't. */
1719 * Set up the control arguments to the shell. This is based on the
1724 /* Create the pipe by which we'll get the shell's output. */
1731 * If the shell has an output filter (which only csh and ksh have by default),
1733 * shell.
1743 if (shell->noPrint == NULL || shell->noPrint[0] == '\0')
1747 * XXX: What happens if shell->noPrint occurs on the boundary of
1752 while ((ep = strstr(p, shell->noPrint)) != NULL) {
1765 p = ep + shell->noPrintLen;
1780 * In the output of the shell, the 'noPrint' lines are removed. If the
1858 * to the shell description), we print the line, preceded
1871 * do anything in the default shell, this bug has gone
2089 shellName = shell->name;
2110 if (shell->errFlag == NULL)
2111 shell->errFlag = "";
2112 if (shell->echoFlag == NULL)
2113 shell->echoFlag = "";
2114 if (shell->hasErrCtl && shell->errFlag[0] != '\0') {
2116 strcmp(shell->errFlag, &shellErrFlag[1]) != 0) {
2121 shellErrFlag = str_concat2("-", shell->errFlag);
2129 * Return the string literal that is used in the current command shell
2135 return shell->newline;
2264 /* Find a shell in 'shells' given its name, or return NULL. */
2279 * Parse a shell specification and set up 'shell', shellPath and
2283 * line The shell spec
2289 * 'shell' points to a Shell structure (either predefined or
2290 * created from the shell spec), shellPath is the full path of the
2291 * shell described by 'shell', while shellName is just the
2295 * A shell specification consists of a .SHELL target, with dependency
2302 * name Name of shell.
2303 * path Location of shell.
2310 * hasErrCtl True if shell has error checking control
2418 "%s: No matching shell", newShell.name);
2422 shell = sh;
2442 "%s: No matching shell", shellName);
2446 shell = sh;
2448 shell = bmake_malloc(sizeof *shell);
2449 *shell = newShell;
2455 if (shell->echoOn != NULL && shell->echoOff != NULL)
2456 shell->hasEchoCtl = true;
2458 if (!shell->hasErrCtl) {
2459 if (shell->echoTmpl == NULL)
2460 shell->echoTmpl = "";
2461 if (shell->runIgnTmpl == NULL)
2462 shell->runIgnTmpl = "%s\n";
2467 * by the shell specification.