[Matrix-SIG] Interactive shell

jhauser@ifm.uni-kiel.de jhauser@ifm.uni-kiel.de
Sat, 8 May 1999 23:41:17 +0200 (CEST)


Thank's for the patch. I think this can be done, but I'm not sure, it
should be. For example the cd command is now not clear who executes
it, the underlying shell or the interpreter. The shell will probably
be used by people who are just starting with Python and NumPy. I fear
some confusion if they don't see the difference between valid python
code and some special commands which the can't use in batch scripts.
I followed your idea and have made the rest of the line after the
@command available for the shell method. This leads to some more
intiutive input like in @cd /home/joeuser.

I have made a new version where the main enhancement is a starting help 
system. See the announcement on the list. 
but I will think about it a little bit more.

__Janko

Pearu Peterson writes:
 > 
 > On Tue, 27 Apr 1999 jhauser@ifm.uni-kiel.de wrote:
 > 
 > > -special shell commands starting with a @
 > >  @pwd @cd @who @whos @logon @logoff @clean
 > >  These commands don't need ()
 > 
 > Here follows an idea:
 > I felt that these commands don't need '@' (and '!') either. So, below is
 > my hack of prefilter function. As a result I can do:
 > >>> ls -l
 > >>> dir
 > >>> dir shell
 > >>> who
 > etc
 > 
 >     def prefilter(self, line):
 >         sline=string.strip(line)
 >         i=string.find(sline,' ')
 >         if i<0: cline,aline=sline,''
 >         else: cline,aline=sline[:i],sline[i+1:]
 >         if line and string.strip(line)[0] == '!':
 >             self.handle_shell_escape(line)
 >             return '' # Empty string is needed here!
 >         elif line and string.strip(line)[0] == '?':
 >             return self.handle_help(line)
 >         elif line and string.strip(line)[0] == '@':
 >             return self.handle_magic(line)
 >         elif line and sline in
 > ['who','dir','pwd','whos','clear','logon','logoff']: # etc
 >             return self.handle_magic('@'+sline)
 >         elif line and cline in ['cd']: # etc
 >             return self.handle_magic('@'+cline+'('+`aline`+')')
 >      
 > 
 > 
 > _______________________________________________
 > Matrix-SIG maillist  -  Matrix-SIG@python.org
 > http://www.python.org/mailman/listinfo/matrix-sig