Use bash string manipulation instead of basename

Less dependencies and no sub shell.