Rav Huna quotes Rabbi Yochanan as saying that if one is walking in mevaos metunafos he should place his hand on his mouth in order to say Shema. The Gemara raises a contradiction from a different ruling where Rav Huna said that a talmid chacham is forbidden to stand in a makom hatenofes since it is impossible for him to do so without thinking of Torah. The Gemara answers that the second ruling is talking about standing in a makom hatenofes which is assur, whereas the ruling that Rav Huna quoted from Rabbi Yochanan is referring to walking through a makom hatenofes without standing still, in which case one can say Shema (while covering his mouth). However, this answer seems difficult in light of the earlier Gemara on 13b where there is a discussion as to how much of Shema one has to remain still for (due to requiring kavana) and Rabbi Yochanan is the one who says that one has to remain still for the entire first parsha. So according to Rabbi Yochanan one should not be able to say Shema while walking through a makom hatenofes, since he would have to stand still for the first parsha, yet if he stands still it would be assur to say Shema in the makom hatenofes.
Tzvi Hertzberg, New York, USA
Baruch she'Kivanata! Your question is asked by a few Acharonim, cited by the Mesivta edition, 24b, in Yalkut Bi'urim.
1. The Birkas Rosh and Eshel Avraham answer based on Tosfos above (13b, DH Al) who writes that even though Beis Hillel maintains (Mishnah 10b) that everyone may read the Shema in whatever way is most convenient (Rashi writes there that this includes reading it when walking), nevertheless the choice way of doing the Mitzvah is to stand still if one is walking, because one can concentrate better this way. We learn from Tosfos that standing still when saying Shema is only a Mitzvah Min ha'Muvchar. Therefore, if one is afraid that he will miss the last time for reading Shema (which was the scenario in the Gemara on 24b), one may read Shema while walking, and this is why Rebbi Yochanan permitted this there.
2. The Eshel Avraham gives another answer. When Rav Huna said that a Talmid Chacham may not stand in a filthy place, this does not mean literally that he may not stand there but rather that he may not stay there for a prolonged period. If he merely is there for the amount of time it takes to say the first verse or the first Parshah of Shema, and he then immediately moves on, this is permitted.
3. The Yeshu'os Yakov (Orach Chaim 85:1) makes a distinction between the first Parshah of Shema and the second and third. Rebbi Yochanan on 13b was referring only to the first Parshah, while the Sugya on 24b is discussing someone who has already read the first Parshah and is now reading the second and third.
1) I posed your question to one of the Gedolim and he replied that Rebbi Yochanan permits, in case of necessity, saying Shema while walking. This answer is similar to what I cited above (1)in the name of the Birkas Rosh and Eshel Avraham.
2) A few years ago I published a Kuntres called "Teshuvaso ha'Ramah" and wrote in the name of Rav Chaim Kanievsky shlit'a that in case of need it is possible to be lenient and permit saying a Berachah while walking. In fact, the Halichos Shlomo (Hilchos Tefilah 22:5) also writes in the name of Rav Shlomo Zalman Auerbach zt'l that it appears that there is no prohibition against walking when one says a Berachah. However, Rav Shlomo Zalman says that l'Chatchilah it is correct to avoid walking while saying a Berachah.
It seems that we now possess a source from the Gemara for the above Din. Even though the Mishnah Berurah (OC 63:11) writes that one is allowed to read Shema while walking only from "Baruch Shem Kevod" onwards (and some are stringent and say only from "Al Levavecha" onwards), nevertheless we now have a proof from the Gemara and Tosfos that in case of need it is permitted to walk even for the first verse of Shema. The Din of Tosfos is in fact cited by the Mishnah Berurah (63:9). If this is permitted according to the Ikar ha'Din even for the first verse of Shema which is mid'Oraisa, then certainly it should be permitted for a Berachah which is mid'Rabanan. This, then, is a source for the Din of Rav Shlomo Zalman and Rav Chaim Kanievsky that it is possible to be lenient and permit saying a Berachah when walking.
3) According to this it might be possible to resolve another difficulty in Halachah. The Shulchan Aruch (OC 72:4) discusses the case of a burial in the morning where the mourners returned after the burial to receive comforting and the people walk after the mourners from the grave to the "Shurah" where the mourners are comforted. If the comforters have enough time to say even the first verse of the Shema, they should do so. The Bi'ur Halachah (DH v'Kol) asks that the Shulchan Aruch earlier (OC 63:3) says that one may not read the first verse of Shema while walking, so how can the Shulchan Aruch allow them to say the first verse while walking?
4) The Aruch ha'Shulchan (OC 72:4) answers this question and asserts that because of the honor of the mourners and the Mitzvah of comforting them, Chazal were lenient and permitted reading the first verse even while walking. We now have a support for the Aruch ha'Shulchan's argument from Tosfos 13b, that we cited above, that refraining from walking during the first verse is only the preferable way of doing the Mitzvah, but in case of need one is allowed to say it while walking, and therefore Chazal permitted saying it while walking in order to achieve the Mitzvah of honoring and comforting the mourners.
Kol Tuv,
Dovid Bloom