Repository: xonsh/xonsh

Issue:
cat file without eol
In bash:
```
worldmind@host:~$ cat file
FILEDATASTRworldmind@host:~$
```
in xonsh
```
worldmind@host ~ master $ cat file
worldmind@host ~ master $
```
we don't see string from file
looks like problem with buffering


Discussion:
hmm weird. Thanks for reporting @worldmind.  I do not see this behaviour on my machine. Can you please post the output of running the `xonfig` command?
@scopatz 
```
worldmind@host ~ $ xonfig 
+------------------+----------------------+
| xonsh            | 0.6.0                |
| Git SHA          | c29819c5             |
| Commit Date      | Nov 22 17:51:52 2017 |
| Python           | 3.5.3                |
| PLY              | 3.9                  |
| have readline    | True                 |
| prompt toolkit   | None                 |
| shell type       | readline             |
| pygments         | None                 |
| on posix         | True                 |
| on linux         | True                 |
| distro           | debian               |
| on darwin        | False                |
| on windows       | False                |
| on cygwin        | False                |
| is superuser     | False                |
| default encoding | utf-8                |
| xonsh encoding   | utf-8                |
| encoding errors  | surrogateescape      |
+------------------+----------------------+
```
Hello,

I'm happy to be finally giving xonsh a try!

I'm getting an in-between behaviour, where the file without EOL first displays almost as expected (with a suspicious prompt position):

![noeol_1](https://user-images.githubusercontent.com/2227806/38211505-b0255d10-3688-11e8-9b0a-310854d87df7.png)

Once I press Enter, I lose the output:

![noeol_2](https://user-images.githubusercontent.com/2227806/38211506-b34af7b6-3688-11e8-9853-f7d7bbeed6b1.png)

Fyi,

```
(xonsh) marianne@marianne-thinkpad ~ $ xonfig
+------------------+-----------------+
| xonsh            | 0.6.0           |
| Python           | 3.6.5           |
| PLY              | 3.11            |
| have readline    | True            |
| prompt toolkit   | 1.0.15          |
| shell type       | prompt_toolkit  |
| pygments         | 2.2.0           |
| on posix         | True            |
| on linux         | True            |
| distro           | debian          |
| on darwin        | False           |
| on windows       | False           |
| on cygwin        | False           |
| is superuser     | False           |
| default encoding | utf-8           |
| xonsh encoding   | utf-8           |
| encoding errors  | surrogateescape |
+------------------+-----------------+
```
 
Hi @mkcor -- we're glad you're trying it out!
I believe the issue you are seeing is the same as #2093 and is specific to the `prompt_toolkit` backend.  Unfortunately we don't have a fix for that one yet... :(
Heh, or rather, I have forgotten that there is a workaround -- @mkcor you should be able to set the envvar `$XONSH_APPEND_NEWLINE=True` which will force the insertion of a newline if there is not one present to avoid the overdrawing.
@gforsyth with workaround it is work, thanks
I am suprised that the default is `False`.  Seems like we should also be able to check if we are in interactive mode in prompt-toolkit and running in an uncaptured subproc and add the newline.  Or if we don't add it to the output, add it to the display

Resolving patch:
diff --git a/xonsh/base_shell.py b/xonsh/base_shell.py
--- a/xonsh/base_shell.py
+++ b/xonsh/base_shell.py
@@ -344,8 +344,8 @@ def default(self, line):
             tee_out = tee.getvalue()
             self._append_history(inp=src, ts=[ts0, ts1], tee_out=tee_out)
             self.accumulated_inputs += src
-            append_newline = env.get('XONSH_APPEND_NEWLINE')
-            if append_newline and not tee_out.endswith(os.linesep):
+            if (tee_out and env.get('XONSH_APPEND_NEWLINE') and
+                    not tee_out.endswith(os.linesep)):
                 print(os.linesep, end='')
             tee.close()
             self._fix_cwd()
diff --git a/xonsh/environ.py b/xonsh/environ.py
--- a/xonsh/environ.py
+++ b/xonsh/environ.py
@@ -257,6 +257,12 @@ def default_xonshrc(env):
     return dxrc
 
 
+@default_value
+def xonsh_append_newline(env):
+    """Appends a newline if we are in interactive mode"""
+    return env.get('XONSH_INTERACTIVE', False)
+
+
 # Default values should generally be immutable, that way if a user wants
 # to set them they have to do a copy and write them to the environment.
 # try to keep this sorted.
@@ -328,7 +334,7 @@ def DEFAULT_VALUES():
                                                          'share')),
         'XONSHCONFIG': xonshconfig,
         'XONSHRC': default_xonshrc,
-        'XONSH_APPEND_NEWLINE': False,
+        'XONSH_APPEND_NEWLINE': xonsh_append_newline,
         'XONSH_AUTOPAIR': False,
         'XONSH_CACHE_SCRIPTS': True,
         'XONSH_CACHE_EVERYTHING': False,


Test patch: