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.
Unfortunately PR #41 fixed issue by side effect. This PR intends to provide proper fix and little refactoring.
Trouble is that regular expression in sed never matches and thus keep string unchanged.
trimmed=$(echo $RAWDATA1 | sed 's/ *$//g')
What actually trim first space is echoing
$RAWDATA
without quotation marks.echo "$RAWDATA1
would echo string as is, but regexp in sed still wouldn't match.So I tried to go full bash route here, but I could just rewrite sed expression if you prefer that.
There is practically identical block of code which could look better in own reusable function. Only caveat I see here is that this code will work only on bash 4.3+, because of nameref used here.