Comments (7)
did you try this ?
change this line in pbs.py:
processed_args = shlex.split(" ".join(processed_args), posix=True)
and then http://docs.python.org/library/shlex.html#shlex.shlex.escape can kick in:
cc(add_component='\\"checker checker01 10.10.10.105:5000\\"')
maybe when you doing kwargs to command you should do that by default..
from sh.
posix is True by default on shlex.split, if I remember correctly. But here's the result:
In [4]: shlex.split("--derp=%s" % '\\"1 2 3\\"', posix=True)
Out[4]: ['--derp="1', '2', '3"']
But this works:
In [7]: shlex.split("--derp %s" % '\"1 2 3\"', posix=True)
Out[7]: ['--derp', '1 2 3']
from sh.
yeah you are right about posix is True by default...
but in my windows test case
this is the command i want todo:
dir /b /a | find /c /v ""
so I have todo it like that:
find(dir("/b", "/a"),'/c', '/v','\\"\\"'))
for shlex not to drop my ""
maybe that something else that need to be documented
from sh.
as for your case:
else: arg = '--%s="%s"' % (k, v)
I think that will enable you to use shlex.split with no harm...
from sh.
@fruch If I do your way and have a v of "test"", I get "ValueError: No closing quotation". But you're on the right track...using repr() works:
else: arg = "--%s=%r" % (k, v)
from sh.
please also include what the heck "pbs" stands for in the faq :-)
from sh.
@agrover ha! Python (in) Bash Scripts. This was from its early days when it did some (admittedly ugly) things to emulate the look of a bash script, but with the facilities of python. It's a nice short name though, so I kept it :)
from sh.
Related Issues (20)
- RFE: please start making github releases HOT 6
- Automate github releases
- "Bad" signals can't be ignored with _ok_code HOT 5
- cannot import name 'pg_dump' from 'sh' HOT 2
- Github page link 404s HOT 2
- glob wrapper breaks glob(.., root_dir=someething) HOT 1
- Special kwarg _cwd and sh.pushd() not working HOT 5
- baking piped commands HOT 2
- piped commands via ssh? HOT 4
- RFH: Unable to pipe `sudo` process to `sudo` process HOT 3
- sh doesn't print output unless wrapped in print() HOT 1
- Feature proposal: _except callback HOT 6
- documentation has bad example code HOT 1
- Questions about Copilot + Open Source Software Hierarchy HOT 1
- Mention `pbs3` as an alternative for Windows? HOT 4
- Info pushed to stdout instead of variable when invoked with contirb.sudo HOT 6
- sh 1.14.3 breaks isinstance(sh.command_name, sh.Command) HOT 2
- Idiomatic way of handling binary data from commands? HOT 3
- Monkey patch of glob.glob breaks root_dir kwarg HOT 4
- Add GitHub release for 2.0.7 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sh.