Checks platform.system to determine POSIX mode #25

wants to merge 6 commits into

1 participant


This fixes a quoting issue with the shlex module in expand_args on windows. Under posix mode, words in " are expanded. So, 'cat "c:/program files/test.txt"' gets passed in as ['cat', 'c:/program files/test.txt']. With the double quotes removed, the underlying windows os sees two arguments, and fails to find either.

I've added a variable POSIX to hold True or False based upon the results from platform.system(). Anything that needs to check posix mode should use this value.

srathbun added some commits Mar 5, 2012
@srathbun srathbun Added platform check to determine posix mode for expanding arguments. f542146
@srathbun srathbun Very dirty fix for expand_args parsing issue. See kennethreitz#26 (co…
…mment) for details
@srathbun srathbun The rest of the dirty pipe fix dea91b8
@srathbun srathbun Using shlex as a lexer, and we are parsing the return tokens. This is…
… better than before, but it still fails some cases.
@srathbun srathbun All my test {read: use} cases are functional. Properly works for = si…
…gns, pipes, and quotes. The quotes need more testing of edge cases.
@srathbun srathbun Non posix mode does not work for ghostscript. If a filename has a quo…
…te surrounding it, gs does not strip it out. Since " is invalid for filenames on windows, this does not work.

I've configured it to only parse once over the input string, thus avoiding the original reason for switching to Non posix mode.

Also, it is set up to allow setting of posix mode manually if the user needs to.

Non posix mode still handles quotes slightly oddly, in that if a command such as -I"c:/program files/gs/gs9.05/fonts" is input, two tokens are returned.

This can be fixed, if necessary, in Non posix mode since tokens are examined individually, instead of just using shlex.split() and getting a list.
@srathbun srathbun closed this May 2, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment