Allow reading scripts from an anonymous pipe

Bash (and many other shells) provide a nifty feature in "anonymous pipe" or "anonymous fifo" whereby the output of a subshell may be treated as a simple file by the parent shell: http://unix.stackexchange.com/a/156088

Unfortunately, libmproxy complains because that "file" is not a regular file, as os.path.isfile checks, e.g. giving the error "Not a file: /dev/fd/11". This patch is intended to provide for the following use-case:

```
mitmdump -s <(echo "def response(context, flow):\n  flow.response.headers['newheader'] = [`hostname`]")
```

where `hostname` may be replaced with a more complicated lookup.
This commit is contained in:
sethp-jive 2015-09-30 15:55:43 -07:00
parent c6811bd0e8
commit fd8c921a2f
1 changed files with 1 additions and 1 deletions

View File

@ -83,7 +83,7 @@ class Script:
"If your script path contains spaces, "
"make sure to wrap it in additional quotes, e.g. -s \"'./foo bar/baz.py' --args\".") %
args[0])
elif not os.path.isfile(args[0]):
elif os.path.isdir(args[0]):
raise ScriptError("Not a file: %s" % args[0])
return args