forked from tarantool/tarantool
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
console: fix -i being overruled by !isatty()
The interactive mode has been ignored when stdin was not a tty and is no more. Now results of another command can be handled by tarantool. Before the patch: ``` $ echo 42 | tarantool -i LuajitError: stdin:1: unexpected symbol near '42' fatal error, exiting the event loop ``` After the patch: ``` $ echo 42 | tarantool -i Tarantool 2.5.0-130-ge3cf64a6c type 'help' for interactive help tarantool> 42 --- - 42 ... ``` Closes tarantool#5064 NO_DOC=bugfix
- Loading branch information
Showing
3 changed files
with
25 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## bugfix/console | ||
|
||
* Fixed console ignoring `-i` flag in case stdin is not a tty (gh-5064). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
test/app-luatest/gh_5064_console_ignore_i_flag_without_tty_test.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
local t = require('luatest') | ||
local g = t.group() | ||
|
||
local result_str = [[tarantool> 42 | ||
--- | ||
- 42 | ||
... | ||
tarantool> ]] | ||
|
||
g.test_console_ignores_i_flag_without_tty = function() | ||
local cmd = [[printf '42\n' | tarantool -i 2>/dev/null]] | ||
local fh = io.popen(cmd, 'r') | ||
|
||
-- Readline on CentOS 7 produces \e[?1034h escape sequence before tarantool> prompt, remove it. | ||
local result = fh:read('*a'):gsub('\x1b%[%?1034h', '') | ||
|
||
fh:close() | ||
t.assert_equals(result, result_str) | ||
end |