- edited description
escaping curly braces in a tox command doesn't work
I was trying to delete a few specific files using the "find" command, but couldn't get tox to ignore the required curly braces in the command:
py26 runtests: commands[2] | find /Users/.../dev/.../.tox/py26 -name *.so -exec rm \{\} + WARNING:test command found but not installed in testenv cmd: /usr/bin/find env: /Users/.../dev/.../.tox/py26 Maybe forgot to specify a dependency? find: -exec: no terminating ";" or "+" ERROR: InvocationError: '/usr/bin/find /Users/.../dev/.../.tox/py26 -name *.so -exec rm \\{\\} +'
Having "{}" in the tox command breaks since tox looks for a variable named "" in the config. The above is the result of attempting to escape the curly braces with back-slashes, as per the documentation: You can escape curly braces with the \ character if you need them, ...
My environment:
- OSX 10.8
- Python 3.4.2 (installed via pyenv)
- tox 1.8.1 (installed via pip)
Comments (13)
-
-
Encountered this on tox 2.1.1 on ubuntu 14.04 python 2.7.6.
Made use of find -exec impossible since the slashes were leaked through. Managed to work around with -execdir, since that doesn't require the brackets.
-
I managed to find a "better" workaround by invoking bash in the tox.ini
bash -c \'find {envsitepackagesdir} -name my_directory_criteria -type d -print0 | xargs -0 django-admin.py test [] \'
-
It looks like this feature was introduced in https://bitbucket.org/hpk42/tox/commits/9d7345ef4b2be4f12a30a887fcda30c7b268c245 , and tests in https://bitbucket.org/hpk42/tox/commits/0c8a958f574b9d25eb16343e318cf88495087bd5
However I also cant find any version of tox, or tox incantation, where it works as explained in the documentation.
-
Before that commit in 1.8.x,
\{..\}
would produceTraceback (most recent call last): File "/usr/bin/tox", line 9, in <module> load_entry_point('tox==1.8.0', 'console_scripts', 'tox')() File "/usr/lib/python2.7/site-packages/tox/_cmdline.py", line 25, in main config = parseconfig(args, 'tox') File "/usr/lib/python2.7/site-packages/tox/_config.py", line 42, in parseconfig parseini(config, inipath) File "/usr/lib/python2.7/site-packages/tox/_config.py", line 296, in __init__ self._makeenvconfig(name, section, reader._subs, config) File "/usr/lib/python2.7/site-packages/tox/_config.py", line 359, in _makeenvconfig vc.commands = reader.getargvlist(section, "commands") File "/usr/lib/python2.7/site-packages/tox/_config.py", line 552, in getargvlist commandlist.append(self._processcommand(current_command)) File "/usr/lib/python2.7/site-packages/tox/_config.py", line 581, in _processcommand new_word = self._replace(word) File "/usr/lib/python2.7/site-packages/tox/_config.py", line 730, in _replace return RE_ITEM_REF.sub(self._replace_match, x) File "/usr/lib/python2.7/site-packages/tox/_config.py", line 726, in _replace_match return handler(match) File "/usr/lib/python2.7/site-packages/tox/_config.py", line 697, in _replace_substitution val = self._substitute_from_other_section(sub_key) File "/usr/lib/python2.7/site-packages/tox/_config.py", line 686, in _substitute_from_other_section return self._replace(x) File "/usr/lib/python2.7/site-packages/tox/_config.py", line 730, in _replace return RE_ITEM_REF.sub(self._replace_match, x) File "/usr/lib/python2.7/site-packages/tox/_config.py", line 726, in _replace_match return handler(match) File "/usr/lib/python2.7/site-packages/tox/_config.py", line 697, in _replace_substitution val = self._substitute_from_other_section(sub_key) File "/usr/lib/python2.7/site-packages/tox/_config.py", line 691, in _substitute_from_other_section "substitution key %r not found" % key) tox.ConfigError: ConfigError: substitution key '\\' not found
So it looks like it was a partial fix, avoiding the config layer claiming it as substitution, but the un-quoting part of the fix wasnt done.
-
https://bitbucket.org/hpk42/tox/pull-requests/185 fixes this for me
-
The problem will be how to fix this, without breaking anyone who relies on the current approach. @Marc Abramowitz, do you depend on the current functionality as you implemented it?
-
A reasonable way to avoid this being a breaking change is to use {{..}} as the way to add literals, as that is the same syntax as str.format, and I am guessing that '{foo}' is an illegal variable name (or at least it is an improbable and silly name to be in use as a variable name.).
-
using {{..}} would also be a breaking change, as that is legal syntax; see https://bitbucket.org/hpk42/tox/pull-requests/186
-
I don't depend on the current functionality.
-
- changed status to resolved
add changelog entry for latest PR merge: fix issue212: allow escaping curly brace chars "{" and "}" if you need the chars "{" and "}" to appear in your commands or other ini values. Thanks John Vandenberg.
→ <<cset b609deef30f3>>
-
This issue has been moved to GitHub: https://github.com/tox-dev/tox/issues/212
-
- changed status to on hold
- Log in to comment