bash implementation