]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
STABLE14-pts-process-input-file-and-exit-20080318
authorKevin McBride <klm@endpoint.com>
Tue, 18 Mar 2008 15:59:07 +0000 (15:59 +0000)
committerDerrick Brashear <shadow@dementia.org>
Tue, 18 Mar 2008 15:59:07 +0000 (15:59 +0000)
LICENSE IPL10

 The pts program has a command 'source' to read commands from
 a file.  In the interactive "shell" mode, this command works,
 reading and executing commands until the end of the file and
 then returning to the command shell.

 This command is valid for use as a command line option, but
 does not work. It requires a valid filename as an argument,
 but does not process the file, instead just dropping the user
 into the interactive mode.

 When given as a command line option, pts source SHOULD read
 the file, execute the commands and then exit, according to
 the documentation. It does not currently do this and should
 be fixed.

(cherry picked from commit db4c703131c4fe68e699d873525f1055845545f7)

src/ptserver/pts.c

index a3539f7e2e98f9ddf1a900512d13a372d34a5294..7b90a926521832712726c2734ca7c2653bf23c1a 100644 (file)
@@ -59,6 +59,7 @@ struct authstate {
 int
 pts_Interactive(register struct cmd_syndesc *as)
 {
+    source = stdin;
     finished = 0;
     return 0;
 }
@@ -1177,12 +1178,12 @@ main(int argc, char **argv)
     cmd_SetBeforeProc(GetGlobals, &state);
 
     finished = 1;
+    source = NULL;
     if (code = cmd_Dispatch(argc, argv)) {
        CleanUp(NULL, NULL);
        exit(1);
     }
-    source = stdin;
-    while (!finished) {
+    while (source && !finished) {
        if (isatty(fileno(source)))
            fprintf(stderr, "pts> ");
        if (!fgets(line, sizeof line, source)) {