He fired a shot well,within hearing range of,the bear. Usually that is enough to drive off a black bear, unless the bear has crossed a line and decided to will not be deterred.
As the bears in Jasper National Park, Canada, are not hunted, they have developed a population of "problem bears" which are not afraid of humans.
From not being afraid of humans, it is only one step to testing to see if those human bags of meat make suitable prey.
Not many black bears attack humans; but some do. It almost always comes from a population of bears that do not fear humans.
Some are wilderness bears which never saw a human; some are bears which have become habituated to humans.
I carry a metal whistle and a 9mm. I have not encountered a black bear in years on the trail.