When a person is imprisoned or detained in custody on any criminal charge for want of bail, the person is entitled to a writ of habeas corpus for the purpose of giving bail upon averring that fact in the person's petition, without alleging that the person is illegally confined.
§ 46-22-103, MCA