The Shulchan Aruch · Orach Chayim
אורח חיים ת״וOrach Chayim 406
Siman 406 of 697 in Orach Chayim — 1 se'if
הלכות תחומיןLaws of Techumin· siman 406
Se’if 1א׳
מִי שֶׁיָּצָא חוּץ לַתְּחוּם שֶׁלֹּא לָדַעַת, שֶׁאֵין לוֹ אֶלָּא ד' אַמּוֹת, וְהֻצְרַךְ לִנְקָבָיו, יָכוֹל לָצֵאת מֵהֶם עַד שֶׁיִּמְצָא מָקוֹם צָנוּעַ לִפָּנוֹת; וְעֵצָה טוֹבָה לוֹ שֶׁיִּתְקָרֵב בְּצַד תְּחוּמוֹ, שֶׁאִם לֹא יִמְצָא מָקוֹם צָנוּעַ עַד תְּחוּמוֹ יָכוֹל לִכָּנֵס, וּלְאַחַר שֶׁנִּכְנָס הָוֵי כְּאִלּוּ לֹא יָצָא כֵּיוָן שֶׁנִּכְנַס בִּרְשׁוּת; אֲבָל אִם מָצָא מָקוֹם צָנוּעַ קֹדֶם, לֹא יִכָּנֵס אֶלָּא יִפְנֶה שָׁם וְיִתְרַחֵק מִמָּקוֹם שֶׁנִּפְנָה עַד שֶׁיִּכְלֶה הָרֵיחַ, וְשָׁם יֵשׁ לוֹ ד' אַמּוֹת. וְאִם נִתְרַחֵק מֵהָרֵיחַ וְנִכְנַס בִּתְחוּמוֹ, כְּאִלּוּ לֹא יָצָא. וְאִם יָצָא לָדַעַת, אֵין לוֹ תַּקָּנָה. זֶה שֶׁאָמַרְנוּ בְּהֻצְרַךְ לִנְקָבָיו, יֵשׁ אוֹמְרִים אֲפִלּוּ לִקְטַנִּים וְיֵשׁ אוֹמְרִים דַּוְקָא לִגְדוֹלִים.
One who went out of the Shabbat barrier unknowingly, he only has four amot, and if he needs to "go do the bathroom", he is able to leave from there until he finds a private place to turn; and it is good advice that he approaches the side of the barrier, because if he does not find a private place until the barrier he can enter, and after he enters, it is like he did not leave since he entered with permission; but if he found a private place first, he should not enter except to face there, and he should distance himself from the place he turned until he covers the smell, and there he has four amot. And if he distances himself from the smell and enters into the barrier, it is like he did not leave. And if he went out knowingly, he has no fix. This that we said, regarding the need to "go to the bathroom", there are those who say even for urine and there are those who say specifically for feces.
Shulchan Aruch, Orach Chayim — Torat Emet 363 edition, via Sefaria — public domain
English: Sefaria Community Translation — CC0