If, upon a hearing, the prisoner shall be entitled to his discharge then the judge before whom he is brought shall within two days after the prisoner shall be brought before him discharge the prisoner from his imprisonment, taking his recognizance, with one or more surety or sureties, in any sum according to the judge's discretion, having regard to the nature of the offense, for his appearance the term following in the court of general sessions for the county in which the offense is alleged to have been committed or in the court of such other county in which the alleged offense is properly cognizable, as the case shall require. And the judge shall then certify the writ, with the return thereof, and the recognizance into the court in which such appearance is to be made. But if no legal cause be shown for the imprisonment or restraint the prisoner shall be discharged therefrom.
S.C. Code § 17-17-130