Giter Club home page Giter Club logo

Comments (7)

fruch avatar fruch commented on August 17, 2024

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.

amoffat avatar amoffat commented on August 17, 2024

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.

fruch avatar fruch commented on August 17, 2024

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.

fruch avatar fruch commented on August 17, 2024

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.

amoffat avatar amoffat commented on August 17, 2024

@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.

agrover avatar agrover commented on August 17, 2024

please also include what the heck "pbs" stands for in the faq :-)

from sh.

amoffat avatar amoffat commented on August 17, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.