fix: replace bash-only ${name^^} with portable tr for zsh compatibility#116
Merged
Merged
Conversation
Replace ${level_name^^} (bash 4+ case transformation) with:
$(printf '%s' "$1" | tr '[:lower:]' '[:upper:]')
Fixes zsh 'bad substitution' error when sourcing bash-logger from .zshrc.
Changes in _get_log_level_value() and log_to_journal().
Closes GingerGraham#114
GingerGraham
approved these changes
May 26, 2026
Owner
GingerGraham
left a comment
There was a problem hiding this comment.
Tested myself locally, change looks good and in line with what I was expecting from my initial diagnosis and bug report in #114
GingerGraham
requested changes
May 26, 2026
Owner
GingerGraham
left a comment
There was a problem hiding this comment.
See in line changes and failed linting https://github.com/GingerGraham/bash-logger/actions/runs/26471405342
Could you split the declaration of the local and it's assignment over two lines and then it's good to go.
Owner
|
Test's good, but just need to address linting/style issues and then this is good to commit |
GingerGraham
approved these changes
May 27, 2026
Owner
GingerGraham
left a comment
There was a problem hiding this comment.
local declaration and assignment now split. Looks good
GingerGraham
pushed a commit
that referenced
this pull request
May 27, 2026
## [2.5.3](2.5.2...2.5.3) (2026-05-27) ### Bug Fixes * replace bash-only ${name^^} with portable tr for zsh compatibility ([#116](#116))
Owner
|
🎉 This PR is included in version 2.5.3 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When sourcing bash-logger from
.zshrc, the_get_log_level_valuefunction produces abad substitutionerror because${level_name^^}is bash 4+ specific syntax for uppercase conversion. zsh does not support this.Fix
Replace the bash-specific
${name^^}case transformation with a portable equivalent usingtr:Also removed the now-redundant
^^in the two case statements that used it.Affected functions:
_get_log_level_value()— converts level name to uppercase for case matchinglog_to_journal()— normalises level name for journald integrationTesting
The fix was verified with
bash -n logging.sh(syntax check passed). Thetrcommand is POSIX-compliant and works in both bash and zsh.Closes #114