Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dependence on perl #41

Merged
merged 3 commits into from
Aug 29, 2024
Merged

Conversation

KarolKozlowski
Copy link
Contributor

Perl is an unnecessary dependency, the same can be achieved using bash built-in.

@markusressel
Copy link
Owner

Hey @KarolKozlowski , looks great 👍
Does this also work on FreeBSD and Mac?

@markusressel markusressel added the enhancement New feature or request label Jul 8, 2024
@markusressel markusressel self-assigned this Jul 8, 2024
@KarolKozlowski
Copy link
Contributor Author

KarolKozlowski commented Jul 12, 2024

I don't have easy access to neither of those, but I've got myself a OSX Ventura in kvm and prepared the following script to test this line in isolation:

#!/usr/bin/env bash

current_index=28203
file_count=44558

echo "uname:"
uname -a
echo "bash version:"
bash --version
echo "test: current_index=${current_index} file_count=${file_count}"
progress_percent=$(printf '%0.2f' "$(($current_index*10000/$file_count))e-2")
echo "Should be '63.29': ${progress_percent}" 

Te result from osx looks good:

uname:
Darwin Karols-iMac-Pro.local 22.6.0 Darwin Kernel Version 22.6.0: Mon Apr 22 20:54:28 PDT 2024; root:xnu-8796.141.3.705.2~1/RELEASE_X86_64 x86_64
bash version:
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin22)
Copyright (C) 2007 Free Software Foundation, Inc.
test: current_index=28203 file_count=44558
Should be '63.29': 63.29

I'll get myself a freebsd in a similar fashion and get back to you with the results.

@KarolKozlowski
Copy link
Contributor Author

Sorry it took so long, got myself a FreeBSD on an old laptop, here are the results:

karol@freebsd:~/tmp $ ./zfs-test.sh
uname:
FreeBSD freebsd 14.0-RELEASE-p9 FreeBSD 14.0-RELEASE-p9 #0: Tue Aug  6 19:52:06 UTC 2024     [email protected]:/usr/obj/usr/src/amd64.amd64/sys/GENERIC amd64
bash version:
GNU bash, version 5.2.26(1)-release (amd64-portbld-freebsd14.0)
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
test: current_index=28203 file_count=44558
Should be '63.29': 63.29

So it looks good, moreover it works with the default interpreter as well (before installing bash):

karol@freebsd:~/tmp $ ./zfs-test.sh
uname:
FreeBSD freebsd 14.0-RELEASE-p9 FreeBSD 14.0-RELEASE-p9 #0: Tue Aug  6 19:52:06 UTC 2024     [email protected]:/usr/obj/usr/src/amd64.amd64/sys/GENERIC amd64
bash version:
./zfs-test.sh: bash: not found
test: current_index=28203 file_count=44558
Should be '63.29': 63.29

@markusressel
Copy link
Owner

@KarolKozlowski No worries, looks good! 👍
Shellcheck is still complaining about SC2004 though, is this a valid complain?

@KarolKozlowski
Copy link
Contributor Author

@markusressel It was, just pushed the fix, and since the code changed I tested it again and it still looks good.

@markusressel
Copy link
Owner

Perfect! Merging now, thx for the efforts!

@markusressel markusressel merged commit 9cea80a into markusressel:master Aug 29, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants