Chromium Code Reviews| Index: go/env.py |
| diff --git a/go/env.py b/go/env.py |
| index 71fe12a6ee399c403aa5934ef245124366a8f57e..c541409f9caa2c5d4b8b19908f82ae2e25226784 100755 |
| --- a/go/env.py |
| +++ b/go/env.py |
| @@ -32,7 +32,19 @@ new = bootstrap.prepare_go_environ() |
| if len(sys.argv) == 1: |
| for key, value in sorted(new.iteritems()): |
| if old.get(key) != value: |
| - print 'export %s=%s' % (key, pipes.quote(value)) |
| + # Replace special characters with their escaped form. This will allow them |
|
mithro
2016/07/07 02:09:39
Can you move this into a function?
dnj (Google)
2016/07/07 03:43:30
Done.
|
| + # to be interpreted by the shell using the $'...' notation. We will only |
| + # use the $'...' notation if there was an escaped character in the string. |
| + orig_value = value |
| + for f, r in ( |
| + ('\n', r'\n'), |
|
mithro
2016/07/07 02:09:38
This is kind of confusing, I think
('\n', '\\n')
dnj (Google)
2016/07/07 03:43:30
Done.
|
| + ('\b', r'\b'), |
| + ('\r', r'\r'), |
| + ('\t', r'\t'), |
| + ('\v', r'\v')): |
| + value = value.replace(f, r) |
| + print 'export %s=%s%s' % (key, ('$') if orig_value != value else (''), |
| + pipes.quote(value)) |
| else: |
| exe = sys.argv[1] |
| if exe == 'python': |