regolith-linux / regolith-i3xrocks-config

Regolith customization of i3xrocks.
Other
29 stars 49 forks source link

Use awk instead of bash printf to avoid octal conversion #99

Closed moritzheiber closed 3 years ago

moritzheiber commented 3 years ago

bash has this weird way of converting numbers with leading zeros to octals, which means that the todo blocket will throw an error whenever just a zero is passed into it. This works around it by using awk to printf the statement.

Also added tests to verify the script gives us proper output.

cheginit commented 3 years ago

So that's what it is. It seems that td count returns the value with some additional characters so here's how I worked around it:

ntask=$(td count $FILTER | sed 's/[^0-9]*//g')
COUNT="$(printf ' %-2s' "${ntask: :-1}")"

But your solution is more elegant. Another PR is being merged, can you please wait for a bit till we merge that one then rebase? BWT, thanks for the test, it was needed!

moritzheiber commented 3 years ago

Sure thing, no problem.

cheginit commented 3 years ago

We merged that PR, so please rebase.