Merge pull request #2569 from neruok/catout

cat outputs in configured encoding
This commit is contained in:
Gil Forsyth 2018-01-04 15:43:51 -05:00 committed by GitHub
commit e9476a9734
Failed to generate hash of commit
2 changed files with 17 additions and 1 deletions

13
news/catout.rst Normal file
View file

@ -0,0 +1,13 @@
**Added:** None
**Changed:** None
**Deprecated:** None
**Removed:** None
**Fixed:**
* cat from xoreutils now outputs in configured encoding
**Security:** None

View file

@ -1,10 +1,13 @@
"""Implements a cat command for xonsh."""
import os
import builtins
from xonsh.xoreutils.util import arg_handler
def _cat_single_file(opts, fname, stdin, out, err, line_count=1):
env = builtins.__xonsh_env__
enc = env.get('XONSH_ENCODING')
if fname == '-':
f = stdin
elif os.path.isdir(fname):
@ -37,7 +40,7 @@ def _cat_single_file(opts, fname, stdin, out, err, line_count=1):
if opts['show_ends']:
_r = _r + b'$'
try:
print(_r.decode('unicode_escape'), flush=True, file=out)
print(_r.decode(enc), flush=True, file=out)
except:
pass
return False, line_count