The term shooting yourself in the foot was derived from WWI trench warfare.
To do so meaning a pass back from the front and survival.
Like most idioms, it is used out of context and is generally one of my most hated, behind "just giving you a heads up".
A Brazilian bank robber has taken the expression to new heights, though, by actually shooting himself in the foot.
Check out the security camera footage here...