提交 6a104b45 编写于 作者: C Cleber Rosa

selftests/functional/test_basic.py: make echo output safe

In the module global scope, "man echo" is executed to attempt to
determine if it's a GNU echo.  But, "man echo" in a locale such
as UTF-8 produces funky copyright characters:

  $ LANG=en_US.UTF-8 man echo | chardetect -
  <stdin>: windows-1252 with confidence 0.73

Which can not be decoded by the UTF-8 codec, producing
UnicodeDecodeErrors.  Even if that wasn't the case, it's better to
control the locale of command that can generate varied output, and
that we depend on.

  $ LANG=C man echo | chardetect -
  <stdin>: ascii with confidence 1.0
Signed-off-by: NCleber Rosa <crosa@redhat.com>
上级 1401f3cf
......@@ -138,7 +138,9 @@ CC_BINARY = probe_binary('cc')
GNU_ECHO_BINARY = probe_binary('echo')
if GNU_ECHO_BINARY is not None:
if probe_binary('man') is not None:
echo_manpage = process.run('man %s' % os.path.basename(GNU_ECHO_BINARY)).stdout
echo_cmd = 'man %s' % os.path.basename(GNU_ECHO_BINARY)
echo_manpage = process.run(echo_cmd, env={'LANG': 'C'},
encoding='ascii').stdout
if b'-e' not in echo_manpage:
GNU_ECHO_BINARY = probe_binary('gecho')
READ_BINARY = probe_binary('read')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册