"And on the eighth day the flesh of his foreskin shall be circumcised," and we expound: "On the eighth day" — even on Shabbat, for this word "on the day" is superfluous, and it should have written "and on the eighth," since it refers back to days, as it is written previously: "she shall be impure seven days" (see Shabbat 132b). And this word "his foreskin" is also superfluous, since the location of the circumcision was already explained in Parshat Lech Lecha, and it should have written: "And on the eighth day he shall be circumcised." And we expound from "flesh" regarding the matter of a baheret (133a), that one may circumcise in the place of a baheret, and it was explained in Yoreh Deah there. And from "his foreskin" we expound that specifically a certain foreskin overrides Shabbat, but not a doubtful foreskin, such as an androgynos who is a doubtful male and doubtful female — we do not circumcise him on Shabbat. And similarly not when the time is in doubt, such as if he was born during bein hashemashot, which is after sunset, for immediately after sunset the doubt begins. But before sunset, even if they have already accepted Shabbat, this is not relevant to the time of the circumcision. Now, in the case of one born on Shabbat during bein hashemashot — it is obvious that he is circumcised on Sunday, for even on weekdays in such a case he is circumcised the next day, for perhaps it is not yet his eighth day; but even if he was born on Friday during bein hashemashot — we do not circumcise him on Shabbat, for perhaps it was day and his time was on Friday eve, and it would be a circumcision not in its time on Shabbat, which does not override Shabbat. And there are times when due to doubt he is circumcised on the twelfth day, and it was explained in Yoreh Deah there. And similarly, one born when he is circumcised — we do not circumcise him on Shabbat, and this is also included in "his foreskin," meaning a complete foreskin and not one born circumcised, for even if we are obligated to draw from him the blood of the covenant, nevertheless it does not override Shabbat (135a). And the primary purpose of the verse is for an androgynos and for one born circumcised, for regarding a doubt of time it was not necessary, as we would automatically not desecrate Shabbat by hand out of doubt (Tosafot ibid.). But an androgynos, since we are obligated to circumcise him, and similarly one born circumcised who requires the drawing of the blood of the covenant, I would have said that they should circumcise them on Shabbat — the verse comes to teach us that they should not circumcise them on Shabbat. And the Rif wrote that one born circumcised is a legal doubt whether we desecrate Shabbat for him or not, see there, and according to this it is not relevant to say that we expound it from the verse, and it must be said that the verse is only for an androgynos. (And it requires further study, for Rabbi Yehuda holds in the Mishnah 134b that an androgynos overrides Shabbat, and it is explained in the Gemara 137 that he expounds from the verse "every male" that an androgynos is obligated in circumcision from the Torah, and the Rabbis hold that he is not obligated; if so, even for an androgynos it is not necessary. And the Tosafot 135a at the end of the heading starting with "v'lo" wrote that the primary purpose of the verse is for one born circumcised, see there, and if so, according to the Rif it is difficult and requires further study, and look closely into it).
"וביום השמיני ימול בשר ערלתו", ודרשינן: ביום השמיני - אפילו בשבת, דהך 'ביום' מיותר הוא, והוה ליה לכתוב 'ובשמיני', שהרי אימים קאי, כדכתיב מקודם: "וטמאה שבעת ימים" (עיין שבת קל"ב:). והך 'ערלתו' גם כן מיותר, שהרי כבר נתבאר בפרשת לך לך מקום המילה, והוה ליה לכתוב: 'וביום השמיני ימול', ודרשינן מבשר לענין בהרת (קל"ג.), שיכול למול במקום בהרת, ונתבאר ביורה דעה שם. ומ'ערלתו' דרשינן דדוקא ערלה ודאי דוחה שבת, ולא ערלה ספק, כגון אדרוגינוס שהוא ספק זכר ספק נקבה - אין מלין אותו בשבת. וכן לא כשהזמן ספק, כגון שנולד בין השמשות, והיינו אחר שקיעת החמה, דמיד אחר השקיעה מתחיל הספק. אבל קודם השקיעה, אפילו אם כבר קבלו שבת, אין זה שייך לזמן המילה. והנה בנולד בשבת בין השמשות - פשיטא שנמול ליום א', דאפילו בימי החול כהאי גוונא נמול למחר, דשמא אינו עדיין שמיני שלו, אלא אפילו נולד ביום ו' בין השמשות - אין מלין אותו בשבת, דשמא היה יום וזמנו בערב שבת, והוה בשבת מילה שלא בזמנה דאינה דוחה שבת. ויש לפעמים שמצד הספק נמול לשנים עשר, ונתבאר ביורה דעה שם. וכן בנולד כשהוא מהול - אין מלין אותו בשבת, וזה נכלל גם כן ב'ערלתו', כלומר ערלה גמורה ולא נולד מהול, דאפילו אם מחויבים להטיף ממנו דם ברית, מכל מקום אינו דוחה שבת (קל"ה.). ועיקר קרא הוא לאנדרוגינוס ולנולד כשהוא מהול, דלספק זמן לא אצטריך, דממילא לא נחלל שבת מספק בידים (תוספות שם). אבל אנדרוגינוס, כיון שמחויבים למולו, וכן נולד מהול שצריך להטיף ממנו דם ברית, הייתי אומר שימולו אותן בשבת - קמ"ל קרא שלא ימולו אותם בשבת. והרי"ף כתב דנולד מהול הוה ספיקא דדינא אם מחללין עליו שבת אם לאו ע"ש, ולפי זה לא שייך לומר דמקרא דרשינן, וצריך לומר דקרא אינו אלא לאנדרוגינוס. (וצ"ע דהא ר"י סבירא ליה במשנה קל"ד: דאנדרוגינוס דוחה שבת, ומפרש בגמרא קל"ז דדריש מקרא ד'כל זכר' דאנדרוגינוס מחויב במילה מן התורה, ורבנן סבירא ליה דאינו מחויב, אם כן גם לאנדרוגינוס אין צריך. והתוספות קל"ה. בסוף ד"ה 'ולא' כתבו דעיקר קרא לנולד מהול ע"ש, ואם כן להרי"ף קשה וצ"ע ודו"ק).