In any habeas corpus action brought by a state penitentiary or county jail inmate, the judge shall award reasonable attorney's fees to the respondent, if, in the judgment of the court, the habeas corpus action was brought frivolously by the petitioner.
In all habeas corpus actions which result in a denial or dismissal of a writ of habeas corpus, the court shall make a specific finding whether or not the habeas corpus action was brought frivolously by the petitioner.
For purposes of this section, "brought frivolously," shall mean that the petitioner petitioned the court for a writ of habeas corpus based upon claims which either had no basis in fact or, even if the factual allegations were true, they did not, as a matter of law, justify any relief to the petitioner; provided, however, that the court, in its discretion, may determine that the action was not brought frivolously when the action involves a material issue of law that has not been settled by statute or by supreme court decision in this state.
Idaho Code § 12-122