The premise of "The Captain's Replacement" storyline in which the ship's crew behaves eccentrically in order to dissuade Captain Donahue from taking over command from Captain Stubing closely resembles the plot from the Season Two premiere of M*A*S*H* (1972) "Divided We Stand" in which the staff of the 4077th deliberately tries to trick an army psychiatrist into believing they are unstable in order to prevent him from breaking up the unit. McLean Stevenson played both Captain Donahue in this episode and Lt. Col. Henry Blake on M*A*S*H*.
At about 30:05 there is a sound of someone passing gas.