[IPython-dev] [Ipython-svndiff] 2609 - prefilter: make sure that ! gets precedence

Fernando Perez fperez.net@gmail....
Mon Aug 13 12:44:12 CDT 2007


On 8/13/07, ipython-svndiff@scipy.org <ipython-svndiff@scipy.org> wrote:
> Author: vivainio
> Date: 2007-08-13 12:39:08 -0500 (Mon, 13 Aug 2007)
> New Revision: 2609
>
> Modified:
>    ipython/trunk/IPython/prefilter.py
> Log:
> prefilter: make sure that ! gets precedence
>
> Modified: ipython/trunk/IPython/prefilter.py
> ===================================================================
> --- ipython/trunk/IPython/prefilter.py  2007-08-13 17:37:41 UTC (rev 2608)
> +++ ipython/trunk/IPython/prefilter.py  2007-08-13 17:39:08 UTC (rev 2609)
> @@ -48,6 +48,11 @@
>          self.pre, self.iFun, self.theRest = splitUserInput(line)
>
>          self.preChar       = self.pre.strip()
> +
> +        # special override for !, which MUST always have top priority
> +        if not self.preChar and self.iFun.startswith('!'):
> +            self.preChar = self.pre = '!'

Please don't hardcode the special escapes, that's why we have a table
of constants:

        # escapes for automatic behavior on the command line
        self.ESC_SHELL  = '!'
        self.ESC_SH_CAP = '!!'
        self.ESC_HELP   = '?'
        self.ESC_MAGIC  = '%'
        self.ESC_QUOTE  = ','
        self.ESC_QUOTE2 = ';'
        self.ESC_PAREN  = '/'

If anyone ever writes a customized shell and modifies this, hardcoded
symbols deep inside are going to make a mess.

f


More information about the IPython-dev mailing list