I punched a black bear in the nose once, through the tent, of course. This was in the summer at a state campground. It was making the rounds of campsites looking for food. Didn't hit it very hard and the critter just shook it off. Didn't scare him away, but when he didn't find food in our camp he ambled off.
I've had bear, racoon and other critters near my tent other times. Most times, I just lie there and listen, and they move off. If they do some pressing on the tent, I usually yell at it then. Well, rather quietly try to shoo off whatever it is. If it doesn't leave, I raise my voice. If it keeps pushing, only once, as described above, I punch it. Come to think of it, I believe I've rolled over a coon and skunk or two from inside the tent as well.
In Grizzly country, I do pack heat so I would have a piece inside the tent with me. I would never shoot through the tent. What if it's your buddy/hunting partner playing a trick on you? Mine wouldn't, but there are some oddballs out there.
From what I've read on the effectiveness of bear spray, in the future, I'll carry some of that. I think it would be a much more effective deterrent on a pesky bear in camp. Shooting would be a last resort.