Home

Awesome

<!-- Copyright (c) 2021 Jesús Lázaro This software is released under the MIT License. https://opensource.org/licenses/MIT -->

GitHub

IceCream-bash - Never use echo to debug again

Overview

Simple implementation of IceCream for Bash.

An example output from the test file 1 is:

(./test_file_1.sh,main) 16: test_a - string
(./test_file_1.sh,main) 17: test_a - string
(./test_file_1.sh,main) 18: test_b - string_a string_b string_c
(./test_file_1.sh,main) 19: test_b - string_a string_b string_c
(./test_file_1.sh,main) 20: test_c - 5
(./test_file_1.sh,main) 21: test_c - 5
(./test_file_1.sh,main) 22: test_d - stringab string_aa
(./test_file_1.sh,main) 23: test_d - stringab string_aa

How do I use it?

Requirements

This script has been tested in Bash v5. Comments about issues in other versions are welcomed.

Installation

There are two ways to include this commands in your script:

  1. Source ic.sh in your script:
source ic.sh
  1. Just copy the content of the script to your script.

Usage

This project provides two different commands:

  1. ic prints the line, file name, function name, name of variable and value.
  2. ict prints all the call tree.
  3. The icp and ictp variants just print a message string, with similar line preambles.

The usage in both cases is the same:

variable="hello"
ict variable
ic variable

Several examples can be found in the test subdir.

Test

There is a test suite with example. It has been done using the Bats-core testing framework for Bash.

IceCream in Other Languages

Delicious IceCream should be enjoyed in every language.

License

This library is free software; you can redistribute it and/or modify it under the terms of the MIT license. See LICENSE for details.