Awesome
<!-- Copyright (c) 2021 Jesús Lázaro This software is released under the MIT License. https://opensource.org/licenses/MIT -->IceCream-bash - Never use echo
to debug again
Overview
Simple implementation of IceCream for Bash.
- This project aims to:
- Print the value of a variable as well as the position in the program.
- Work with normal variables, arrays and associative arrays (only values are printed, not keys).
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:
- Source
ic.sh
in your script:
source ic.sh
- Just copy the content of the script to your script.
Usage
This project provides two different commands:
ic
prints the line, file name, function name, name of variable and value.ict
prints all the call tree.- The
icp
andictp
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.
- Python: IceCream
- Dart: icecream
- Rust: icecream-rs
- Node.js: node-icecream
- C++: IceCream-Cpp
- C99: icecream-c
- PHP: icecream-php
- Go: icecream-go
- Ruby: Ricecream
- Java: icecream-java
- R: icecream
- Lua: icecream-lua
- Clojure(Script): icecream-cljc
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.