
According to one of the sages, Rava, religious law does not require intention for the fulfillment of a commandment. It is enough, technically, to perform the commandment. Therefore one who takes a shofar on Rosh Hashanah and begins to blow it as a musical instrument, not for the purposes of fulfilling the commandment, is considered to have fulfilled the commandment to blow the shofar, for the sages stated “commandments do not require intention.” The scholars ask: If one does not have to be aware to fulfill a commandment, why was it ruled that a person who is walking past a synagogue on Rosh Hashanah and suddenly hears the sound of a shofar must intend to fulfill the commandment of hearing the blowing of the shofar? Answer: The requirement that he must intend to fulfill the commandment means that he must consciously identify the sound as that of a shofar and not as that of something else, but if he thought he heard the sound of something else, for example the sound of a donkey, did not fulfill the commandment even if in practice he did hear the sound of a shofar. The scholars went on to ask: If one does not have to be aware that he is fulfilling a commandment, why was it ruled that one who blows the shofar must have intention? The one who blows obviously knows that he is blowing the shofar, yet he was required to intend to and be aware that he is fulfilling a commandment. Answer: There is no real need for the one blowing the shofar to intend his notes to fulfill the commandment, but he must be careful to blow the halachically required notes with their proper length.
(Babylonian Talmud, Tractate Rosh Hashanah 28b)