TheLocehiliosan / yadm

Yet Another Dotfiles Manager
https://yadm.io/
GNU General Public License v3.0
5.07k stars 176 forks source link

/opt/homebrew/bin/yadm: line 660: local_classes: bad array subscript #411

Closed davay closed 2 years ago

davay commented 2 years ago

Describe the bug

Anytime I run Yadm, though the command succeeds, it also throws an error message:

Note: Doesn't seem to be breaking anything..?

opt/homebrew/bin/yadm: line 660: local_classes: bad array subscript

To reproduce

  1. Run command 'yadm status'
  2. Run command 'yadm diff'
  3. Run command 'yadm commit'

Environment

TheLocehiliosan commented 2 years ago

Can you also tell me what version of Bash is being used? (yadm version should report this)

davay commented 2 years ago

@TheLocehiliosan updated in the description, thanks

TheLocehiliosan commented 2 years ago

Thanks for the report. It looks like the implementation of multiple classes uses a Bash 4.2 feature.

It shouldn't be too hard to fix.

I'm away from a computer right now, but I think line 660 needs to change

local_class="${local_classes[-1]:-}"

To

local_class="${local_classes[${#local_classes[@]}-1]:-}"

TheLocehiliosan commented 2 years ago

I only had a moment, but I pushed a possible fix to branch fix/411. If you can test that, and let me know how it goes.

Looking at the code, I also think it may be viable to just remove that line too.

I'll have to look tonight when I'm back.

TheLocehiliosan commented 2 years ago

I've been able to recreate this problem, and I've refined the fix a little.

I'll release 3.2.1 tonight, which addresses this problem.

TheLocehiliosan commented 2 years ago

Fixed in 3.2.1