Skip to content

Commit 169a0cf

Browse files
committed
print "ok ." only in terminal
1 parent 39a9d8b commit 169a0cf

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/main.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// You should have received a copy of the GNU General Public License along with
1313
// liorforth. If not, see <https://www.gnu.org/licenses/>.
1414

15-
use std::io::{Read, Write};
15+
use std::io::{IsTerminal, Read, Write};
1616
use std::ops::{BitAnd, BitOr, BitXor, Shl, Shr};
1717

1818
/// Forth's basic data type. Holds a number
@@ -1420,12 +1420,15 @@ macro_rules! default_fixed_sized_environment {
14201420
}
14211421

14221422
fn main() {
1423+
let terminal = std::io::stdin().is_terminal();
14231424
default_fixed_sized_environment!(environment);
14241425
for maybe_line in std::io::stdin().lines() {
14251426
match maybe_line {
14261427
Ok(line) => {
14271428
environment.interpret_line(line.as_bytes());
1428-
println!(" ok. ");
1429+
if terminal {
1430+
println!(" ok. ");
1431+
}
14291432
std::io::stdout().flush().unwrap();
14301433
}
14311434
_ => break,

0 commit comments

Comments
 (0)