fix infinite loop on commands

The array was not being shifted for all cases. This lead to the command
succeeding, but being retried anyway.