Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

simulate shell expansion on %run arguments, at least tilde expansion #591

Closed
wants to merge 1 commit into from

2 participants

@hmeine

I like to start scripts using %run instead of from the shell, but this prevents the use of paths starting with ~ for my home directory.

This patch simply applies os.path.expanduser to sys.argv; there might be a better place and possibly a more complete expansion implementation, but this really scratches an itch.

@minrk
Owner

That seems nice, thanks!

@minrk minrk referenced this pull request from a commit
@minrk minrk Merge PR #591
closes gh-591
7deb8e8
@minrk minrk closed this pull request from a commit
@minrk minrk Merge PR #591
closes gh-591
7deb8e8
@minrk minrk closed this in 7deb8e8
@ellisonbg ellisonbg referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@mattvonrocketstein mattvonrocketstein referenced this pull request from a commit in mattvonrocketstein/ipython
@minrk minrk Merge PR #591
closes gh-591
b970f54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 1 deletion.
  1. +5 −1 IPython/core/magic.py
View
6 IPython/core/magic.py
@@ -1595,7 +1595,11 @@ def magic_run(self, parameter_s ='',runner=None,
# Make sure that the running script gets a proper sys.argv as if it
# were run from a system shell.
save_argv = sys.argv # save it for later restoring
- sys.argv = [filename]+ arg_lst[1:] # put in the proper filename
+
+ # simulate shell expansion on arguments, at least tilde expansion
+ args = map(os.path.expanduser, arg_lst[1:])
+
+ sys.argv = [filename]+ args # put in the proper filename
if opts.has_key('i'):
# Run in user's interactive namespace
Something went wrong with that request. Please try again.