I need to implement an SVN pre-commit hook which executes a script that itself is stored in SVN.
I can use the svn cat
command to pipe that script to the Python interpreter, as follows:
svn cat file://$REPO/trunk/my_script.py | python - --argument1 --argument2
However, my_script.py
itself requires data to be piped on STDIN.
That data is not stored in a file; it is stored on the network. I would prefer not to have to download the data to a temporary file, as normally I could pipe it to a Python program:
curl http://example.com/huge_file.txt | python my_script.py
I'm not sure how to combine both of these pipes.
I figured out how to do this without creating any temporary files, but not strictly with "pipes".
curl http://example.com/huge_file.txt | python <(svn cat file://$REPO/trunk/my_script.py) --argument1 --argument2
I used the "anonymous file descriptor" construct in Bash, which can be used in place of any file path.
E.g.
python my_script.py
would be equivalent to
python <(cat my_script.py)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With