最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - Seaming incorrect parsing of a string in shlex - Stack Overflow

programmeradmin1浏览0评论

So I have a program that is passing down commands to a remote host and using shlex library to parse the args that way a incompleted quotation will not be sent down. And I notice this behavior

here is my intended behavior and working behavior on a string like this:

>>> lexer = shlex.shlex('"aaaaaaaaaaaaaaaa')
>>> list(lexer)
ValueError: No closing quotation 

However for

>>> lexer = shlex.shlex('"\\"')
>>> list(lexer)
['"\\"']

Which of course when I run this on the remote host we are getting a waiting since its running this in bash "\". I would expect the above input to also give me a Value Error since the string is not closed.

Is this shlex intended behavor and if so why?

发布评论

评论列表(0)

  1. 暂无评论