This week I spoke about an interesting Ohr HaChaim. Yosef told his brothers not to worry about having sold him since in the end it all turned out for the best. The Ohr HaChaim writes that this is similar to someone who tries to poison another person and in the end mistakenly gives that person a cup of wine. Since in the end of the day nothing bad happened the attempted murderer is patur even from dinei shamayim.
The Kli Chemdah among others asks that this is against a gemara in Nazir 23a. The gemara says that if a woman becomes a nazir, and drinks wine not knowing that her husband had previously annulled her vow, that she is still chayav malkos m’d’rabanan. The gemara compares it to someone who eats a piece of meat thinking it is chazir and in the end it turns out to be kosher. We see from here that one is punished for bad intentions even if they did not lead to any aveirah.
The Kli Chemdah answers that there is a difference between aveiros Bein Adam L’Makom and Bein Adam L’Chaveiro. By Bein Adam L’Makom, HKBH knows your thoughts and it makes no difference if you only thought about the aveirah or you did the aveirah. Even though we say you are generally not punished for your thoughts that is only where no action occurred. However, here, since you did an action, albeit a muttar action, you are still punished. By Bein Adam L’Chaveiro, since people only know your deeds and not your thoughts you are not punished for your thoughts.
Another teretz is found in the Beis Yitzchak Siman 8. He says if the end result was a dvar mitzvah then you don’t get punished. But if the end result is a dvar reshus you are punished. He says there is a Ran in Shabbos like this. I did find a rayah to this idea in Shut Sharei Deia Siman 36. The gemra in Sanhedrin says the cemetery workers who bury the bodies on Yom Tov should not get punished because they are doing a mitzvah.
L’halacha the Pri Megadim discusses if a person who thinks he is eating treife and winds up eating kosher, is he posul l’eidus. According to the Rambam (Hilchos Nezirus), such a person should get malkos d’rabanan and therefore he should be posul l’eidus. He writes in Teivas Gema Parshas Mattos that it depends on why we give the malkos. Rashi in Nazir says it is only l’migdar milsa so you would not be posul l’eidus. The Rambam implies it is to punish you for attempting to do an aveirah. In that case you would be pasul l’eidus. Tosafos holds like the Rambam in terms of why we would give malkos, but paskens we don’t give malkos in this case. According to both rashi and Tosafos you would not be pasul l’eidus although for different reasons.