Skip to content

Commit 5dfa7ac

Browse files
authored
Fix up interactive repl checks (#950)
1 parent 5e6192f commit 5dfa7ac

5 files changed

Lines changed: 21 additions & 9 deletions

File tree

compiler+runtime/include/cpp/jtl/terminal.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,6 @@ namespace jtl::terminal
7979
};
8080

8181
size get_size();
82-
bool is_interactive();
82+
bool is_stdin_interactive();
83+
bool is_stdout_interactive();
8384
}

compiler+runtime/src/cpp/jank/terminal_repl_client.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ namespace jank::terminal_repl
187187

188188
static jtl::option<std::string> read_line(std::string const &prompt)
189189
{
190-
if(!jtl::terminal::is_interactive())
190+
if(!jtl::terminal::is_stdin_interactive())
191191
{
192192
std::string input;
193193
if(!std::getline(std::cin, input))
@@ -265,7 +265,7 @@ namespace jank::terminal_repl
265265
return __rt_ctx->current_ns()->name->to_code_string() + suffix;
266266
});
267267

268-
if(!jtl::terminal::is_interactive())
268+
if(jtl::terminal::is_stdin_interactive())
269269
{
270270
ic_set_history(".jank-repl-history", 200);
271271
init_isocline();
@@ -351,7 +351,7 @@ namespace jank::terminal_repl
351351
__rt_ctx->in_ns_var->deref().call(make_box<obj::symbol>(util::cli::opts.target_module));
352352
}
353353

354-
if(!jtl::terminal::is_interactive())
354+
if(jtl::terminal::is_stdin_interactive())
355355
{
356356
ic_set_history(".jank-native-repl-history", 200);
357357
init_isocline();

compiler+runtime/src/cpp/jtl/string_builder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ namespace jtl
306306

307307
string_builder &string_builder::operator()(terminal::text_style const s) &
308308
{
309-
if(!terminal::is_interactive())
309+
if(!terminal::is_stdout_interactive())
310310
{
311311
return *this;
312312
}

compiler+runtime/src/cpp/jtl/terminal.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,22 @@ namespace jtl::terminal
4444
#endif
4545
}
4646

47-
bool is_interactive()
47+
bool is_stdin_interactive()
4848
{
4949
#if defined(_WIN32)
5050
return true;
5151
#else
52-
static bool const res{ isatty(STDIN_FILENO) != 0 && isatty(STDOUT_FILENO) != 0 };
52+
static bool const res{ isatty(STDIN_FILENO) != 0 };
53+
return res;
54+
#endif
55+
}
56+
57+
bool is_stdout_interactive()
58+
{
59+
#if defined(_WIN32)
60+
return true;
61+
#else
62+
static bool const res{ isatty(STDOUT_FILENO) != 0 };
5363
return res;
5464
#endif
5565
}

compiler+runtime/src/jank/jank/perf/core.jank

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,10 @@ namespace jank::perf::core
8787
(when (and (cpp/jank.util.is_dynamic_runtime)
8888
(not= 3 (.-runtime_optimization_level cpp/jank.util.cli.opts)))
8989
(println (print/color :bright-red "warning:")
90-
"The optimization level is"
90+
"The current optimization level is"
9191
(str "-O" (.-runtime_optimization_level cpp/jank.util.cli.opts))
92-
"while the max is -O3. Benchmarks results may vary greatly between optimization levels."))
92+
"while the max is -O3.\n"
93+
" Benchmarks results may vary greatly between optimization levels."))
9394

9495
(when (not= cpp/jank.util.cli.compilation_eagerness.eager
9596
(.-eagerness cpp/jank.util.cli.opts))

0 commit comments

Comments
 (0)