The Sanskrit root shaMs/shAs meant (and is cognate with the root of) censure, but its meaning was much wider: related words could mean all forms of loudly asking, all the way from praise to punish. In particular, with the prefix A- (representing a duration or limit, often the sense of completely) it meant prayer/asking for or teaching etc. In these senses it is very old, but the meaning later specialized to wishing for someone, i.e. benediction; and this is the meaning that has survived in the modern Indian languages. The use of this word as a name may not be very old, and almost certainly derives from this meaning.