10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * CDDL HEADER START
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * The contents of this file are subject to the terms of the
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Common Development and Distribution License (the "License").
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * You may not use this file except in compliance with the License.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * See the License for the specific language governing permissions
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * and limitations under the License.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * When distributing Covered Code, include this CDDL HEADER in each
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * If applicable, add the following below this CDDL HEADER, with the
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * fields enclosed by brackets "[]" replaced with your own identifying
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * information: Portions Copyright [yyyy] [name of copyright owner]
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * CDDL HEADER END
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Use is subject to license terms.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Execute one commandline
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Included files
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe#include <mksh/dosys.h> /* doshell(), doexec() */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Defined macros
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * typedefs & structs
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Static variables
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * File table of contents
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowestatic void redirect_stderr(void);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * dosys(command, ignore_error, call_make, silent_error, target)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Check if command string contains meta chars and dispatch to
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * the proper routine for executing one command line.
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Return value:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Indicates if the command execution failed
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Parameters:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * command The command to run
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * ignore_error Should make abort when an error is seen?
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * call_make Did command reference $(MAKE) ?
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * silent_error Should error messages be suppressed for pmake?
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * target Target we are building
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Global variables used:
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * do_not_exec_rule Is -n on?
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * working_on_targets We started processing real targets
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowedosys(register Name command, register Boolean ignore_error, register Boolean call_make, Boolean silent_error, Boolean always_exec, Name target)
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe register wchar_t *q;
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Strip spaces from head of command string */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe while (iswspace(*p)) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe if (*p == (int) nul_char) {
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* If we are faking it we just return */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* no_action_was_taken is used to print special message */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Copy string to make it OK to write it. */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe (void) wcscpy(q, p);
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe /* Write the state file iff this command uses make. */
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * Run command directly if it contains no shell meta chars,
10d63b7db37a83b39c7f511cf9426c9d03ea0760Richard Lowe * else run it using the shell.