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.
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.