Skip to content

Commit 87af330

Browse files
committed
Don't emit ANSI sequence escape codes in shell in OTP prior to R16
1 parent 3ae634a commit 87af330

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/elixir/lib/io/ansi.ex

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,14 @@ defmodule IO.ANSI do
3737
"""
3838
@spec terminal? :: boolean
3939
def terminal?(device // :erlang.group_leader) do
40-
match?({:ok, _}, :io.columns(device))
40+
if :erlang.system_info(:otp_release) < 'R16' and
41+
Process.whereis(:user) != device do
42+
# Shell prior to R16 doesn't support ANSI escape
43+
# sequences
44+
false
45+
else
46+
match?({:ok, _}, :io.columns(device))
47+
end
4148
end
4249

4350
@doc "Resets all attributes"

0 commit comments

Comments
 (0)