Compatibility to bash 3 #2

Merged
efelon merged 3 commits from dev into main 2022-03-22 14:34:20 +01:00
3 changed files with 27 additions and 4 deletions

23
CHANGELOG.md Normal file
View File

@@ -0,0 +1,23 @@
# Changelog
## Todo
- [ ] Tests on different platforms (e.g. busybox)
## [0.2](https://winklerfamilie.eu/git/efelon/rdlink/releases/tag/v0.2) - 2022-03-22
* Fix pattern substitution bugs (found with bash 3.2.57)
* Test successful on
* Ubuntu x86_64 (Ubuntu 20.04.4 LTS)
**GNU bash, version 3.2.57**
## [0.1](https://winklerfamilie.eu/git/efelon/rdlink/releases/tag/v0.1) - 2022-03-22
* First relase
* behavior for normal cases same as readlink -f
* Tests successful on
* Raspberry Pi OS aarch64/arm64 (Debian GNU/Linux 11 (bullseye))
**GNU bash, version 5.1.4**
* Ubuntu x86_64 (Ubuntu 20.04.4 LTS)
**GNU bash, Version 5.0.17**

View File

@@ -169,7 +169,7 @@ rl::cleanpath() {
# Remove multiple / # Remove multiple /
while [[ "${work:-}" = *"//"* ]]; do while [[ "${work:-}" = *"//"* ]]; do
work="${work//'//'/'/'}" work="${work/\/\///}"
done done
info " rl::cleanpath result: ${work}" info " rl::cleanpath result: ${work}"
@@ -191,7 +191,7 @@ rl::normalize() {
# Remove /./ and /.$ sequences. # Remove /./ and /.$ sequences.
rex_tmp='/\.(/|$)' rex_tmp='/\.(/|$)'
while [[ "$work" =~ $rex_tmp ]]; do while [[ "$work" =~ $rex_tmp ]]; do
work="${work/"${BASH_REMATCH[0]}"/"${BASH_REMATCH[1]/$//}"}" work="${work/${BASH_REMATCH[0]}/${BASH_REMATCH[1]/$//}}"
done done
# Remove leading ./ # Remove leading ./

View File

@@ -47,7 +47,7 @@ rl::printPath() {
local inputwidth=${config_path_width} local inputwidth=${config_path_width}
if (( flag_extendedOutput )); then if (( flag_extendedOutput )); then
printf -- "%-3d Inp: %-${config_path_width}s ---" ${testnum} "${input}" printf -- "%-5d Inp: %-${config_path_width}s ---" ${testnum} "${input}"
else else
# Truncate input string on the left if longer than $config_path_width # Truncate input string on the left if longer than $config_path_width
if (( ${#input} > ${config_path_width} )) ; then if (( ${#input} > ${config_path_width} )) ; then
@@ -97,7 +97,7 @@ rl::testcmp() {
printf " %b\n" "${testresult_graphic}" printf " %b\n" "${testresult_graphic}"
if (( ! testresult )); then if (( ! testresult )); then
# Test failed # Test failed
printf " Result: %s\n Exp: %s\n" "${actual}" "${expect}" printf " Result: %s\n Exp: %s\n" "${actual}" "${expect}"
if (( flag_verbose )); then if (( flag_verbose )); then
[ -e "${input}" ] && printf "\n Subject:\n" && ls -al "${input}" [ -e "${input}" ] && printf "\n Subject:\n" && ls -al "${input}"