Skip to content

chore(update): drop no-op checksum sed#18

Open
CheapFuck wants to merge 1 commit into
codam-coding-college:mainfrom
CheapFuck:chore/update-drop-noop-checksum-sed
Open

chore(update): drop no-op checksum sed#18
CheapFuck wants to merge 1 commit into
codam-coding-college:mainfrom
CheapFuck:chore/update-drop-noop-checksum-sed

Conversation

@CheapFuck

Copy link
Copy Markdown

What

In towel update --apply, the checksum verification piped the .sha256 through a sed before sha256sum -c:

# sha256sum -c expects the filename column to match the local file; rewrite it.
sed "s/${tarball}$/${tarball}/" "$checksum" | /usr/bin/sha256sum -c - >/dev/null 2>&1

The substitution s/${tarball}$/${tarball}/ replaces the filename with itself, so it never changes anything. The comment claims it rewrites the filename column, but the code is a no-op.

Why it's safe to drop

The release checksum is produced in .releaserc.yml with:

sha256sum "towel-${nextRelease.version}.tar.gz" > "towel-${nextRelease.version}.tar.gz.sha256"

That writes a bare filename in the standard two-space format (<hash> towel-<ver>.tar.gz). The tarball is downloaded under that same bare name into $tmpdir, and verification runs after cd "$tmpdir", so sha256sum -c "$checksum" matches the local file directly — no rewriting needed.

Change

 (
 	cd "$tmpdir"
-	# sha256sum -c expects the filename column to match the local file; rewrite it.
-	sed "s/${tarball}$/${tarball}/" "$checksum" | /usr/bin/sha256sum -c - >/dev/null 2>&1
+	/usr/bin/sha256sum -c "$checksum" >/dev/null 2>&1
 ) || {

No behavior change; removes dead code and a misleading comment.

Verification

  • sha256sum -c <file>.sha256 verifies a release-format checksum directly (confirmed locally).
  • shellcheck -x and shfmt -d pass on install, towel, and all towel-* scripts.

The checksum verification piped the .sha256 through
`sed "s/${tarball}$/${tarball}/"` before `sha256sum -c`. That substitution
replaces the filename with itself, so it never changes anything — the
accompanying comment ("rewrite it") describes behavior the code doesn't have.

The release checksum is generated by `.releaserc.yml` with
`sha256sum "towel-<ver>.tar.gz"`, which writes a bare filename in the standard
two-space format. Since the tarball is downloaded under that same bare name into
$tmpdir and verification runs from there, `sha256sum -c "$checksum"` matches the
local file directly.

Remove the no-op sed and its misleading comment, verifying the downloaded
tarball directly. No behavior change; less dead code.
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.

1 participant