BSD 4_4 release
[unix-history] / usr / src / usr.bin / apply / apply.c
index bb3ebf0..57d18e1 100644 (file)
@@ -1,13 +1,32 @@
-static char sccsid[] = "@(#)apply.c    4.1     (Berkeley)      %G%";
+/*-
+ * Copyright (c) 1983, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * This module is believed to contain source code proprietary to AT&T.
+ * Use and redistribution is subject to the Berkeley Software License
+ * Agreement and your Software Agreement with AT&T (Western Electric).
+ */
+
+#ifndef lint
+static char copyright[] =
+"@(#) Copyright (c) 1983, 1993\n\
+       The Regents of the University of California.  All rights reserved.\n";
+#endif /* not lint */
 
 
-/*%cc -s -O %
+#ifndef lint
+static char sccsid[] = "@(#)apply.c    8.1 (Berkeley) 6/6/93";
+#endif /* not lint */
+
+/*
  * apply - apply a command to a set of arguments
  *
  *     apply echo * == ls
  *     apply -2 cmp A1 B1 A2 B2   compares A's with B's
  *     apply "ln %1 /usr/fred/dir" *  duplicates a directory
  */
  * apply - apply a command to a set of arguments
  *
  *     apply echo * == ls
  *     apply -2 cmp A1 B1 A2 B2   compares A's with B's
  *     apply "ln %1 /usr/fred/dir" *  duplicates a directory
  */
+#include <paths.h>
 #include <stdio.h>
 #include <stdio.h>
+
 char   *cmdp;
 #define        NCHARS 512
 char   cmd[512];
 char   *cmdp;
 #define        NCHARS 512
 char   cmd[512];
@@ -15,6 +34,8 @@ char  defargs=1;
 #define        DEFARGCHAR      '%'
 char   argchar=DEFARGCHAR;
 int    nchars;
 #define        DEFARGCHAR      '%'
 char   argchar=DEFARGCHAR;
 int    nchars;
+extern char *getenv();
+
 main(argc, argv)
        char *argv[];
 {
 main(argc, argv)
        char *argv[];
 {
@@ -32,7 +53,7 @@ main(argc, argv)
                --argc; ++argv;
        }
        if(argc<2){
                --argc; ++argv;
        }
        if(argc<2){
-               fprintf(stderr, "usage: apply [-14] [-a%] cmd arglist\n");
+               fprintf(stderr, "usage: apply [-#] [-ac] cmd arglist\n");
                exit(1);
        }
        argc -= 2;
                exit(1);
        }
        argc -= 2;
@@ -109,7 +130,7 @@ char *s;
        char *shell = getenv("SHELL");
 
        if ((pid = fork()) == 0) {
        char *shell = getenv("SHELL");
 
        if ((pid = fork()) == 0) {
-               execl(shell ? shell : "/bin/sh", "sh", "-c", s, 0);
+               execl(shell ? shell : _PATH_BSHELL, "sh", "-c", s, 0);
                _exit(127);
        }
        if(pid == -1){
                _exit(127);
        }
        if(pid == -1){