Alan Shepard’s first trip into space was only supposed to last 15 minutes, so NASA didn’t worry much about Shepard having to use the bathroom up there. Thus, the astronaut thought nothing of slugging down a bunch of coffee and OJ for his pre-flight breakfast. But then takeoff was delayed, and nature called.
After more than three hours of lying on his back due to delays, with just minutes left until takeoff, Shepard told mission control he just couldn't hold it anymore. "Man, I gotta pee," he told Gordon Cooper, who was stationed at the nearby blockhouse
After some discussion, NASA's scientists concluded that it was probably safe for him to pee in his spacesuit once its electrics were temporarily switched off. According to Freedom 7 mission's post-flight debriefing, Shepard managed to avoid electrocuting himself (which would have been embarrassing for NASA, to say the least), but his suit's electronic biosensors short-circuited. It probably smelled pretty bad in there, too.
Today’s astronauts still do pretty much the same thing on vessels that aren’t outfitted with toilets. They get outfitted with space-age adult diapers known as “Maximum Absorbency Garments” and just let loose in their suits. [The Week]