exec.c revision 379
1179055Sjfv#ifndef lint 2171384Sjfvstatic const char *rcsid = "$Id: exec.c,v 1.4 1993/09/04 05:06:47 jkh Exp $"; 3205720Sjfv#endif 4179055Sjfv 5179055Sjfv/* 6179055Sjfv * FreeBSD install - a package for the installation and maintainance 7179055Sjfv * of non-core utilities. 8179055Sjfv * 9179055Sjfv * Redistribution and use in source and binary forms, with or without 10179055Sjfv * modification, are permitted provided that the following conditions 11179055Sjfv * are met: 12179055Sjfv * 1. Redistributions of source code must retain the above copyright 13179055Sjfv * notice, this list of conditions and the following disclaimer. 14179055Sjfv * 2. Redistributions in binary form must reproduce the above copyright 15179055Sjfv * notice, this list of conditions and the following disclaimer in the 16179055Sjfv * documentation and/or other materials provided with the distribution. 17179055Sjfv * 18179055Sjfv * Jordan K. Hubbard 19179055Sjfv * 18 July 1993 20179055Sjfv * 21179055Sjfv * Miscellaneous system routines. 22179055Sjfv * 23179055Sjfv */ 24179055Sjfv 25179055Sjfv#include "lib.h" 26179055Sjfv 27179055Sjfv/* 28179055Sjfv * Unusual system() substitute. Accepts format string and args, 29179055Sjfv * builds and executes command. Returns exit code. 30179055Sjfv */ 31171384Sjfv 32179055Sjfvint 33179055Sjfvvsystem(const char *fmt, ...) 34171384Sjfv{ 35185352Sjfv va_list args; 36171384Sjfv char cmd[FILENAME_MAX * 2]; /* reasonable default for what I do */ 37171384Sjfv int ret; 38171384Sjfv 39171384Sjfv va_start(args, fmt); 40171384Sjfv vsprintf(cmd, fmt, args); 41171384Sjfv#ifdef DEBUG 42194875Sjfvprintf("Executing %s\n", cmd); 43194875Sjfv#endif 44194875Sjfv ret = system(cmd); 45171384Sjfv va_end(args); 46171384Sjfv return ret; 47171384Sjfv} 48171384Sjfv 49171384Sjfv