mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00
Merge pull request #2569 from neruok/catout
cat outputs in configured encoding
This commit is contained in:
commit
e9476a9734
2 changed files with 17 additions and 1 deletions
13
news/catout.rst
Normal file
13
news/catout.rst
Normal file
|
@ -0,0 +1,13 @@
|
|||
**Added:** None
|
||||
|
||||
**Changed:** None
|
||||
|
||||
**Deprecated:** None
|
||||
|
||||
**Removed:** None
|
||||
|
||||
**Fixed:**
|
||||
|
||||
* cat from xoreutils now outputs in configured encoding
|
||||
|
||||
**Security:** None
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue