17-35. When the party bailed or remanded.
If it appears that the party has been legally committed for any criminal offense, or if it appears by the testimony offered with the return of the writ, or upon the hearing thereof, that the party is guilty of such an offense, although the commitment is irregular, the court or judge shall proceed to let such party to bail, if the case is bailable and good bail is offered; if not, the court or judge shall forthwith remand such party to the custody or place him under the restraint from which he was taken, if the person or officer, under whose custody or restraint he was, is legally entitled thereto; if not so entitled, the court or judge shall commit such party to the custody of the officer or person legally entitled thereto.