Bash Tips: Debug Language Quirks with a REPL

Harness the power of instant feedback

March 5, 2023

Another Short Introduction to Bash

The command-line interface (CLI) or terminal is a text-only way of interacting with a computer system. It provides an alternative to the standard GUI and allows users to more directly execute actions, bypassing the often cumbersome abstractions of a user interface. As a commonly used interface, CLI is similar in kind to web or mobile, and many applications have an implementation specifically designed to work exclusively in the terminal.

REPL

In particular, several programming languages have a read-evaluate-print loop (REPL) that runs in the terminal. I've found this mode to be helpful for quickly debugging and experimenting with language features. Here are some example snippets I have run using a REPL:

Javascript Examples


!!{}
// true
      

!!''
// false
      

!![]
// true
      

!!"true"
// true
      

!!"false"
// true
      

[1, 2, 3, 4, 5].slice(1, 2)
// [ 2 ]
      

[1, 2, 3, 4, 5].splice(1, 2)
// [ 2, 3 ]
      

Python Examples


[i for i in range(10) if i % 3 == 0]
# [0, 3, 6, 9]
      

[
  (i, j)
    for i in range(2)
    for j in range(2)
]
# [(0, 0), (0, 1), (1, 0), (1, 1)]