Fix bug in getcommand introduced in PR 4299
Merge pull request #4304 from AndresTanasijczuk/fix_getcommand

Fix bug in getcommand introduced in PR 4299. Fixes #4279