What saved your life was the fact that you didn't run right off. Once you run the bear sees you as a food source and will eat you. If you stand your ground it sees you as a predator or at the least an equal. A bear knows food runs and is hard to catch. Something it wants to steer clear of stands its ground.
PS: A rattel snake is somethig to be scared of a black bear isn't. I can tell you don't know much about bears or you would know that seeing one that close at all was a treat. A bear is a very hard animal to actually find out in the open and when you do you usually only catch a glimpse before it runs away.