Exactly right- when tent-camping up here, I sleep with a 12-gauge Remington 870 loaded with alternating slugs and 00 buckshot. (I mean literally sleep with it- it's not leaning against a tree outside, or in a gun rack in a vehicle. It's right next to me. So far, I haven't shot my foot off during the night- but I had a lot of experience sleeping with loaded weapons in the Army. I am not suggesting that everyone do this, but I am saying that if a bear decides to drag you off and eat you, he is not likely to allow you to go and get your weapon first...)
Two other tricks I learned while living in Alaska and working as a bush pilot: keep one round of birdshot [my pick is the second one, following a slug] to use to go for the beast's eyes if surprised closeup. But expect one VERY annoyed bear.
The other is during the hours of darkness, use a 12-gauge magnesium *Dragon's breath* ground signal flare/incendiary round as the first shot at night. Whether the beast is blinded or set ablaze, the result will be a bear no longer interested in you as a source of either protein or amusement. I once had to discourage a ranger who was going to fire one vertically as an aircraft signal, thinking the round was a conventional aerial flare round, which they're certainly not. See pic below.
The only bear I've killed was a brownie, at a distance of about 35 feet, coming my way. I hit him one time with a softpoint from a .303 British Enfield, and had the bolt thrown and a second round ready for him in less time than it took for the ejected fired case to hit the ground. But the bear dropped like a puppet whose strings had been cut, for which I was most grateful, and no second shot [nor third, fifth or tenth, which I was prepared to deliver] was needed.
The shotgun is the prefered weapon for general purpose work or when hunting isn't really the point of the exercise, however. A lot of the *old guy* pilots preferred a double barrel, and that answer had worked for some of them a LONG time. And doubles don't freeze up from sleet.