ipython/ipython — pull request #1414 by minrk (2012-02-18 23:15:43+00:00)
Title: ignore errors in shell.var_expand

If an error is raised in the formatter, leave it untransformed. This means that var_expand("$foo") will return "$foo" if `foo` is undefined, but more importantly it will *not* raise when var_expand is used on literal code that doesn't expect to be expanded (e.g. %prun arguments).

A few tests included.

The *real* answer to this problem is to not call var_expand where it shouldn't be called, just as with the argument split. We really treat all magics as shell options, and we shouldn't, but until we get that whole logic cleaned up, this is a temporary solution. The only drawback is that `ls $files` will result in `ls $files` instead of NameError if `files` is undefined, which is the most logical behavior. But valid calls to `%prun` are more important than raising the right error in invalid calls to `ls`.

closes #1412