Mercurial > hg
comparison hgext/color.py @ 24535:1818d4dca75c
color: fix crash in cmd.exe
When 'term' is None because it isn't in the environment, don't iterate over it.
Unfortunately, unsetting $TERM or exporting it as '' doesn't work in the tests,
so there's no way to simulate cmd.exe in the test suite.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Tue, 31 Mar 2015 14:27:45 -0400 |
parents | c14b1d349af3 |
children | 2f88821856eb |
comparison
equal
deleted
inserted
replaced
24534:1925769b4ff8 | 24535:1818d4dca75c |
---|---|
232 realmode = mode | 232 realmode = mode |
233 if mode == 'auto': | 233 if mode == 'auto': |
234 if os.name == 'nt': | 234 if os.name == 'nt': |
235 term = os.environ.get('TERM') | 235 term = os.environ.get('TERM') |
236 # TERM won't be defined in a vanilla cmd.exe environment. | 236 # TERM won't be defined in a vanilla cmd.exe environment. |
237 if not term: | |
238 realmode = 'win32' | |
239 | 237 |
240 # UNIX-like environments on Windows such as Cygwin and MSYS will | 238 # UNIX-like environments on Windows such as Cygwin and MSYS will |
241 # set TERM. They appear to make a best effort attempt at setting it | 239 # set TERM. They appear to make a best effort attempt at setting it |
242 # to something appropriate. However, not all environments with TERM | 240 # to something appropriate. However, not all environments with TERM |
243 # defined support ANSI. Since "ansi" could result in terminal | 241 # defined support ANSI. Since "ansi" could result in terminal |
244 # gibberish, we error on the side of selecting "win32". However, if | 242 # gibberish, we error on the side of selecting "win32". However, if |
245 # w32effects is not defined, we almost certainly don't support | 243 # w32effects is not defined, we almost certainly don't support |
246 # "win32", so don't even try. | 244 # "win32", so don't even try. |
247 if 'xterm' in term or not w32effects: | 245 if (term and 'xterm' in term) or not w32effects: |
248 realmode = 'ansi' | 246 realmode = 'ansi' |
249 else: | 247 else: |
250 realmode = 'win32' | 248 realmode = 'win32' |
251 else: | 249 else: |
252 realmode = 'ansi' | 250 realmode = 'ansi' |