mutt-wizard

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit d0dfcc3c27547e62bd55193b91a6a84344873d2c
parent 943b45340ce6d0249e1e8fc608718a13045584d3
Author: Adrien Czerny <adrien.czerny@moo.com>
Date:   Mon, 31 Mar 2025 16:05:56 +0100

Fix unary operator expected error

On my system running any `mw` command after a fresh install from the AUR, I get:

```
/usr/bin/mw: line 37: [: 1.5: unary operator expected
```

Now the script doesn't error per-se but it does set the `master` and `slave`
variables to wrong values. I'm also not sure how this wasn't raised before;
maybe that's a new bash version thing? I'm on 5.2.37.

Anyway I faffed around trying to fix this, in particular with the `-gt` operator
but it turned out that properly comparing float numbers is a pain in the butt in
bash. I found solutions using `bc` which I thought were weird.

To keep things simple I ended up doing a little substitution on the dot `.`
character and turned these nasty floats into integers, along with using the
`-gt` operator which did the trick on my system. May be unorthodox so feedback
is more than welcome.

Thank you for the great software by the way, lots of gratitude for your work.

Diffstat:
Mbin/mw | 6+++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/bin/mw b/bin/mw @@ -34,7 +34,11 @@ alias mbsync='mbsync -c "$mbsyncrc"' # mbsync >=1.4.0 requires "Far/Near" rather than "Master/Slave." mbver="$(mbsync -v)" mbver="${mbver#* }" -if [ "${mbver%.*}" >= 1.4 ]; then +mbver="${mbver%.*}" +# Comparing two float numbers in bash is a pain in the butt, so we get rid of +# dots and turn them into nice integers +mbver="${mbver/\./}" +if [ "${mbver}" -gt 14 ]; then master="Far" slave="Near" else