Hi, the name of the shell subprocess is hardcoded in the `script'
command. 

The test is as follows:

$ echo $SHELL
/bin/ksh
$ script -c 'echo $0'                                                 
Script started, output file is typescript
sh                              <---- The correct one should be 'ksh'
Script done, output file is typescript

I fixed.


Index: script.c
===================================================================
RCS file: /cvs/src/usr.bin/script/script.c,v
retrieving revision 1.35
diff -u -p -r1.35 script.c
--- script.c    28 Jun 2019 13:35:03 -0000      1.35
+++ script.c    29 Mar 2023 14:26:19 -0000
@@ -308,11 +308,16 @@ void
 doshell(char *cmd)
 {
        char *shell;
-       char *argp[] = {"sh", "-c", NULL, NULL};
+       char *argp[] = {NULL, "-c", NULL, NULL};
 
        shell = getenv("SHELL");
        if (shell == NULL)
                shell = _PATH_BSHELL;
+
+       if ((argp[0] = strrchr(shell, '/')) != NULL)
+               argp[0]++;
+       else
+               argp[0] = shell;
 
        (void)close(master);
        (void)fclose(fscript);


Reply via email to