You have to define "foolish" in that passage. What does it mean, in your view?
Does a drill sargeant act foolishly when he uses vulgar language to beat a point into his recruits' heads?
In one word....Yes
Swear words, used to highlight a point, are used by the drill sargeant to make it abundantly clear that a certain mistake made in training can be lethal on the battlefield. Using clean language would not have the same effect.
So, if the use of swear words by the drill sargeant makes it more likely that a recruit will remember a lesson that might later save his life, do you still consider such language to be "foolish?"