Bracketed accidentals

The code in this snippet defines a new command \bracketAcc to put brackets around an accidental. It also works in chords. Note that you have to use a trailing ‘?’ character after the note in the input to enforce a cautionary accidental.