Skip to content

fix: add B suffix to humanized byte sizes below 1K (#817) - #884

Open
terryrankine wants to merge 1 commit into
peak:masterfrom
terryrankine:fix/humanize-bytes-suffix
Open

terryrankine wants to merge 1 commit into
peak:masterfrom
terryrankine:fix/humanize-bytes-suffix

Conversation

@terryrankine

@terryrankine terryrankine commented Sep 17, 2026 •

Copy link
Copy Markdown

Context

Fixes #817. ls -H / du -H printed sizes below 1 KiB as a bare number (512) next to suffixed values (1.5K).

Fix

strutil.HumanizeBytes appends B when no larger unit applies: 512B. The 1024 boundary is unchanged (1024B, since the existing comparison is b > div).

Tests

TestHumanizeBytes (0, 1, 999, 1023, 1024, 1025, 1536, 1 MiB ±1, 5 GiB, 3 TiB). TestListS3ObjectsWithDashH gains a 20-byte object asserting 20B. No other e2e expectations involve sub-KiB humanized sizes.

Linux, Go 1.24, go test -count=1 -race ./...: all packages ok. gofmt, go vet, staticcheck, unparam, semgrep: clean.

CI note: the test matrix fails before running anything — bitnami/minio:2023.7.18 no longer exists on Docker Hub (fixed by #840). All build and qa jobs pass. The full suite was run locally on Linux as above.

🤖 Generated with Claude Code

ls --humanize and du --humanize printed sizes under 1K as a bare
number, e.g. "123", while larger sizes carry a unit ("1.5K"). Print
"123B" so every humanized size has a unit.

Fixes peak#817

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Humanize option with s5cmd ls does not add suffix when size is bytes

1 participant