ยง 7010. Determination of proceeding. (a) Discharge. If the person is illegally detained a final judgment shall be directed discharging him forthwith. No person detained shall be discharged for a defect in the form of the commitment, or because the person detaining him is not entitled to do so if another person is so entitled. A final judgment to discharge a person may be enforced by the court issuing the order by attachment in the manner prescribed in subdivision (b) of section 7006. (b) Bail. If the person detained has been admitted to bail but the amount fixed is so excessive as to constitute an abuse of discretion, and he is not ordered discharged, the court shall direct a final judgment reducing bail to a proper amount. If the person detained has been denied bail, and he is not ordered discharged, the court shall direct a final judgment admitting him to bail forthwith, if he is entitled to be admitted to bail as a matter of right, or if it appears that the denial of bail constituted an abuse of discretion. Such judgment must fix the amount of bail, specify the time and place at which the person detained is required to appear, and order his release upon bail being given in accordance with the criminal procedure law. (c) Remand. If the person detained is not ordered discharged and not admitted to bail, a final judgment shall be directed dismissing the proceeding, and, if he was actually produced in court, remanding him to the detention from which he was taken, unless the person then detaining him was not entitled to do so, in which case he shall be remanded to proper detention.