Could be, but I know about such things from the Russian Army. You would be sent to a punishment battalion for cowardice or insubordination and you could only get out of one by an incredible display of bravery-of which there were plenty of opportunities as they were invariably thrown against the Germans before any other unit. One of the nasty little secrets of WWII is that many Russian snipers were employed shooting troops who tried to desert.
See the movie "Stalingrad".
Germans who were suspected of fleeing the enemy (Russians), trying to escape, or otherwise not going to their imminent deaths, were assigned the tasks of body retrieval and, as mentioned before, clearing minefields. They earned their right to return to front-line combat.
The Roman legions, at least in the Republic and early Imperial periods, were made up of volunteers. Roman citizens only and, until Marius' reforms there were property qualifications for the right to be Roman soldier! They didn't need punishment battalions. Of course, if a unit did run away, it would be decimated: every 10th man would be executed per l'encouragement l'autres.
Also sounds like something from the Red Army, circa 1918 - 1989.