Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions code/2025-09-03-progress-bar-2/progress-bar
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ fatal() {
progress-bar() {
local current=$1
local len=$2
# if len is zero, fail gracefully
[ ! "$len" ]||[ "$len" -le 0 ]&& return
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style nit: use (( ... )) for arithmetic expressions - please change this to:

if ((len == 0)); then
  return
fi

Or if you'd still like it all on one line I'm ok with:

((len == 0)) && return


local perc_done=$((current * 100 / len))

Expand Down