In a case like that, either a perimeter warning system or dog(s). Warning system might not scare away the bear; although car alarms sure do, dogs, big ones, will scare away most bears. But not all bears.
My Mals are great at scaring grizzlies, but I'm sure if the grizzly wanted to it could kill the dogs in seconds.
But you won't have time to grab the gun unless early warning and bear spray might not be a great idea inside a tent (works outside, but inside?).
Best thing to do if bears are scary, stay out of bear country; especially, in those states with large numbers of big bears like AK, MT, WY, ID....
Good thing is, there are not that many when you consider how many bears there are in certain areas and how many potential meals are walking around, oblivious to their surroundings.
I'm still amazed how many people I see walking in camping areas or on hiking trails in NE WY (just east of Yellowstone/west of Cody) not carrying bear spray or a weapon of any kind. That area is full of grizzlies (and some blacks and big cats). I would bet if the majority could get service they would also be texting at the same time.
And considering how many people are in that area during spring-through fall...