[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon Jul 20 14:24:40 2003 
Subject:Re: poplog interactive mode - PS 
From:A . Sloman 
Volume-ID:1030720.04 

David reports problems caused by this sequence,
	[
	%

i.e. "%" typed at the beginning of a line.

That happens because charin (the character repeater that gets a
character from the terminal), will invoke a shell if you start a line
with any of

	% $ !

as follows
	% = run csh (sometimes this invokes tcsh)
	$ = run sh (set to bash on some linux systems)
	! = run the shell held in the environment variable SHELL

More precisely, if the character after a newline is in the list
	pop_charin_escapes

then (as explained in REF chario) charin invokes sysobey with
a string containing the whole line of input, and giving the
character as argument to sysobey.

If the line is empty it just runs the shell interactively, until
you exit from it.

If the line is non-empty it is given as a command for the shell
to run. Example using the 'who' shell command:

	% pop11
	   <pop11 greeting>
    Setpop
    :
    : % who
    axs      pts/0        Jun 30 14:07
    axs      pts/1        Jun 30 14:07
    axs      pts/3        Jul 20 08:47 (gromit)
    :

You can turn all this off by locally or globally doing:
	[] -> pop_charin_escapes;

(We need a built in procedure that sets up pop11 nicely to be run
from another process, so that it is not necessary to pass a long
argument string to pop11 which can interact badly with the shell
if it includes things like parentheses or ">" e.g. in "->"  ).


> That is the weirdest thing I have come across... I have no Idea why
> pop11 would escape into csh when I'm inside a list (note csh is not my
> default shell either),

If you just run pop11 interactively and start lines with % or $ or !
you will see the behaviour you found.


> PROBLEM 2
> ===========================================================
> ;;; another list that breaks in a slightly different way
> [%
> for i from 1 to ;;; DECLARING VARIABLE i
> 10 do i; endfor;
> %]=>
> Missing name for redirect.

That is the same problem. You have simply passed to the shell
the string
	]=>

If you run csh, or tcsh, and type that in you'll get the same
message. If you do it to bash, you'll get a different message.


> [does it work?]=>
> ===========================================================
>
> Not much seems to have an effect after that happens. When I check 'ps
> -A' after multipe tests of this kind I find a lot of 'active' csh
> processes left over from the pop11 run. (Shouldn't poplog kill any
> external processes it starts when it exits?)

If this is not happening, then maybe sysobey should put them in a list
that is used by sysexit.


> NOTE: I have noticed that pop11 doesn't quite die, it just stops
> printing anything taht happens with a few exceptions, namely: '%' still
> escapes you to a shell, and ;;; DECLARING VARIABLE xyz is still printed,
> but =>, ==>, pr() and nl() don't produce anything. also mishaps aren't
> displayed any more,

Some of this may be due to the fact that it thinks it is still reading
in a list constant expression, because it has not seen the
occurrences of "]" that you typed, and in pop11, text in [ ... ]
is by default not executed.


> even after calling interrupt() (with Roger's
> definition).

But if you type CTRL C, or whatever your normal interrupt character is,
that should invoke setpop and abort the listread.

> PROBLEM 3
> ===========================================================
> ;;; something else that doesn't work
> true -> popnewline;
>
> ;;; MISHAP - mei: MISPLACED EXPRESSION ITEM

Normally white space characters are ignored. The itemiser treats them as
ends of text items and then ignores them. If you make popnewline true
then the itemiser returns a WORD containing just the newline character
at the end of every line.

Think of this as being partly similar to typing a string just at the
beginning of the line, e.g.

: 'newline' 3+3 =>
;;; MISHAP - msep: MISSING SEPARATOR (eg semicolon)
;;; INVOLVING:  'newline' 3
;;; DOING    :  pop_setpop_compiler

In the case where it inserts the newline word just before the 3, the
INVOLVING line will of the error message will not be so clear, because
the newline word prints as a new line!

Maybe we need a debug mode where words containing only tab, space or
newline are printed in a special way, e.g.
	<word newline>

or showing the word_string of the word in the form in which it
could be typed in:
	<word '\n'>

Making popnewline true is useful if
	You want a list read in to retain occurrences of newlines
	You want a macro or syntax word that is reading in text to
		know where the line breaks were,
	etc.

It should not be true when you are compiling ordinary pop11 code, unless
you redefine newlin to be a macro or syntax word that handles the
situation. (Believe me: it is possible.)


> Again, the problem is not with '%' escaping to a system shell per-se,
> but only when it does it whilst inside a list (when it should be
> interpreted as list escape, not escape poplog)

It is arguable that the syntax procedure that reads in lists should
locally assign [] to pop_charin_escapes.

I think this is done in ved_im, because that runs vedsetpop, which does
it.

I hope that makes sense.

Aaron