I am teaching a beginning Unix class, using Redhat Linux 6.1, and use
the "script" command as a way for students to turn in labs.  However,
the script command runs in a subshell, which therefor really messes up
history (which keeps a separate history list for each shell, and only
combines them when you exit the shell).  Trying to figure out just what
was done when from history, when combines with script, is impossible!

   Anyway, I wrote a quice surrounding function to try to get around this
problem.  It basically uses "history -a" annd "history -n"  before and
after calling script, which *should* keep history in order, so the user
will see what he expects (remember, these are beginning users; its really
confusing to look at the history and see things in seemingly random order!)

   However, it doesn't work:  "history -a" is fine, it makes sure the
current history file is up-to-date, so the subshell sees what the user
has done so far.  But "history -n" seems to be run in a subshell, and
when the user next gets a prompt, none of the history from within script
is in his current history list.  If he runs "history -n" from the command
line, it works.  

   So, number one questions is: does a function run in a subshell?  Is there
a description of just how a function works with respect to shells and subshells?

   2: Is there a better way (or any other way) I can keep history in time
      order of the logged in  user, whatever subshells, scripts, and/or
      functions he uses are?

   3. Anybody know where I can get the source code of script(1), to modify
      it at that level?  While I have a function, I'm also checking allowing
      the user to give his own file name for script, and not allowing him
      to over-write a pre-existing typescript.  Also, I try to filter the
      script (not very successfully), so it can be printed; I try to get
      rid of special characters, but only manage to get rid of some of them.

Script is potentially a very nice teaching tool, if I can get it to work
nicely.  Any help with this will be much appreciated!

Thanks,

 -- Stan Isaacs




-- 
To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
as the Subject.

Reply via email to