On July 11, 1947, appellant, hereinafter called relator, filed a petition in the district court for Lancaster County, praying for a writ of habeas corpus. His petition alleged in substance that he was being unlawfully deprived of his liberty by virtue of a pretended judgment, sentence, *615and commitment, rendered, imposed, and ordered by the district court for Chase County on October 31,1945, after trial to a jury which found him guilty as charged in an information, copy of which was attached to the petition. . .
The information charged in substance that on or about January 30, 1945, in Chase County, State of Nebraska, Hugo McAvoy, under the name of J. H. McAvoy, did then and there unlawfully and feloniously make, utter, draw, and deliver a certain described no-fund check, with intent to defraud. The information also separately charged that he was an habitual criminal by reason of three separately described prior convictions for felonies, upon each of which he received a sentence of not less than one year in prison. Admittedly, upon trial to a jury, after previous appointment of counsel to represent him, and after his arraignment and plea of not guilty, a verdict was returned by the jury finding him guilty of the offense charged, and further finding that on two previous occasions he had been convicted of felony charges, for each of which he had been sentenced and committed to prison for terms of not less than one year.
He alleged that thereupon the trial court sentenced him to a term of ten years in the Nebraska State Penitentiary, but that such sentence was null and void because the maximum sentence which could have been imposed upon him for the offense charged was two years, and that since he had served that period, under the law he was entitled to be discharged from custody by respondent.
His petition also alleged in substance that the judgment, sentence, and commitment involved herein, were void because at the time of one previous sentence and commitment to prison for a term of not less than one year upon conviction of a felony, he was in such a state of mind, having had a nervous breakdown, that he knew nothing of the sentence until his power of reasoning had been thereafter restored.
*616The record discloses that on July 18, 1947, the trial court allowed the writ, which was duly served upon appellee, hereinafter called respondent. On return day, July 31, 1947, respondent filed a motion to dissolve the writ of habeas corpus and dismiss the petition for failure to state facts therein sufficient to constitute a cause of action. Upon the same day, respondent also filed a verified return to the writ.
On August 5, 1947, of the same term, the trial court made the following entry: “This cause now comes on to be heard on motion of defendant to dissolve writ of habeas corpus and to dismiss petition and is argued to the Court. Briefs to be presented by parties before submission.”
On September 13, 1947, of the same term, the trial court entered the following order: “Motion of defendant to dissolve writ of habeas corpus heretofore issued herein and to dismiss petition having been heretofore argued, now on this day it appearing to the Court no briefs have been presented, by agreement of parties motion is submitted to the Court, on due consideration whereof, the Court doth sustain said motion and dismiss petition.
“It is therefore considered, ordered and adjudged by the Court that the writ of habeas corpus heretofore issued herein be and hereby is dissolved, and that petition filed herein be and hereby is dismissed.”
Relator made no request for permission to plead further but appealed to this court, assigning as error in substance that: (1) The proceedings of his commitment to the state penitentiary were illegal because section 29-2221, R. S. 1943, governing the Habitual Criminal Act, is not found in the statutes under crimes and punishments but rather is found under the statutes governing criminal procedure, and (2) that his commitment to the penitentiary for a term of ten years was illegal and unlawful because the maximum sentence for the offense charged, as found in count one of the information, was two years’ imprisonment, which was the maximum sen*617tence which could have been imposed upon him even under the Habitual Criminal Act. We conclude that those contentions cannot be sustained.
At the outset it should be stated that the statutes involved are section 28-1212, R. S. 1943, defining the offense charged for which, upon conviction, a maximum sentence of two years’ imprisonment is ordinarily authorized, and section 29-2221, R. S. 1943, of the Habitual Criminal Act, which under circumstances such as were presented to the trial court upon relator’s conviction, authorized a minimum sentence of ten years’ imprisonment for the offense charged, which the court lawfully imposed.
In. that connection, this court held in Jones v. State, 147 Neb. 219, 22 N. W. 2d 710, that: “The charge that one accused of crime is an habitual criminal is not the charge of a distinct offense or crime. It is a direction of attention to facts which under the statute and the crime charged in the information are determinative of the penalty to' be imposed.
“The habitual criminal law does not set out a distinct crime, büt provides that the repetition of criminal conduct aggravates the offense and justifies heavier penalties.
“It is proper to set out the aggravation of a criminal offense justifying the heavier penalties contemplated by the habitual criminal law either in the count charging the crime or in a separate count in the information.”
Relator relies upon Kuwitzky v. O’Grady, 135 Neb. 466, 282 N. W. 396, and Gamron v. Jones, 148 Neb. 645, 28 N. W. 2d 403. However, both of those cases are clearly distinguishable from the case at bar, and cannot control disposition thereof favorable to relator. In those cases, the offender was sentenced to serve one term for the crime or offense charged and another term for being an habitual criminal, as if it were a separate crime or offense, instead of imposing but one valid sentence for the crime charged. The sentence imposed upon relator was strictly within the latter category *618and. as authorized by the habitual criminal statute.
This court has held that: “Habeas corpus will not lie to discharge a person from a sentence of penal servitude where the court imposing the sentence had jurisdiction of the offense, had jurisdiction of the person of the defendant, and the sentence was within the power of the court to impose.” Jackson v. Olson, 146 Neb. 885, 22 N. W. 2d 124. That decision controls relator’s primary contention in the case at bar.
With regard to the question of relator’s alleged mental condition at the time of a previous sentence, this court has held that: “Habeas corpus is a collateral, not a direct, proceeding when regarded as a means of attack upon a judgment sentencing a defendant. It cannot be used as a substitute for a writ of error.
“The right of a person to the writ of habeas corpus depends on the legality or illegality of his detention, and this in turn depends on whether the fundamental requirements of law have been complied with, and not at all on the guilt or innocence of the prisoner.” In re Application of Tail, Tail v. Olson, 145 Neb. 268, 16 N. W. 2d 161.
It was held in Davis v. O’Grady, 137 Neb. 708, 291 N. W. 82, that: “The judgment or sentence of a court of record in a criminal case, when challenged by habeas corpus, is supported by the usual presumptions of validity and regularity. To obtain release from a sentence of imprisonment by habeas corpus, such sentence must be absolutely void.”
That opinion also sustained the constitutionality of the Habitual Criminal Act, and affirmed that it did not set out a distinct criminal offense, but provided that the repetition of criminal conduct aggravated the guilt and justified heavier penalties.
The case of Cochran v. Simpson, 143 Kan. 273, 53 P. 2d 502, presented a situation similar to the one at bar. The court in effect held therein that a relator could not by habeas corpus collaterally attack increased punish*619ment under the habitual criminal statute upon the ground that he was allegedly of unsound mind at the time of a former conviction and sentence, since in such event the conviction might have been voidable but was not void.
In that opinion the court also quoted with approval from Weihofen on Insanity as a Defense in Criminal Law, p. 257, as follows: “Where the defense of irresponsibility by reason of insanity was not raised at the trial the reviewing court will not consider the question on appeal or habeas corpus.”
In McMahan v. Hunter, 150 F. 2d 498, it was said: “Generally, insanity as a bar to the imposition of sentence is a factual issue for the determination of the court having jurisdiction of the offense, and a judgment of sentence by a court of competent jurisdiction may not be collaterally attacked on that issue in a habeas corpus proceedings.” See, also, State ex rel. Novak v. Utecht, 203 Minn. 448, 281 N. W. 775.
It follows that if the relator’s allegations aforesaid were true, they could not be sufficient to state a cause of action in a habeas corpus proceeding.
In 25 Am. Jur., Habeas Corpus, § 126, p. 236, it was said: “It is a settled rule that a petition for writ of habeas corpus should contain a statement of the facts which constitute the illegal restraint, and that the failure to allege a ground of illegality precludes consideration thereof by the court. The statement should consist of direct averments of ultimate facts, as distinguished from conclusions of law, and the circumstances set forth must be such as to warrant the discharge of the prisoner in case they are established.”
As held in In re Application of Tail, Tail v. Olson, supra: “The petition must set forth the facts constituting the illegal detention. It is not sufficient to state the reason the detention is illegal in the form of conclusions. It should show in what the illegality consists and this should be done by stating facts as contradistinguished from mere conclusions of law.
*620“In an application for a writ of habeas corpus if the applicant or petitioner sets forth facts which, if true, would make out a case which would entitle him to his discharge, then the writ is a matter of right and the petitioner should be produced and a hearing held thereon to determine the question of fact presented. But, if he shows by the facts which he sets forth in his application for the writ that he is not entitled to relief, then the writ should be denied.”
A motion to dissolve a writ of habeas corpus is the equivalent of a motion to quash. As stated in 29 C. J., Habeas Corpus, § 170, p. 153: “The sufficiency of the petition upon which it was granted to support the writ tnay generally be questioned before making a return or answer thereto, by motion to quash the writ, but not regularly by a demurrer, although a demurrer in form may be allowed to serve the purpose of a motion to quash or to dismiss.”
In 39 C. J. S., Habeas Corpus, § 86, p. 650, it was said: “On a motion to quash the writ, the allegations of the petition are deemed admitted, and the usual presumptions in support of the jurisdiction of a court of general jurisdiction whose proceedings are collaterally attacked will be made.”
Also, in Ferris, Extraordinary Legal Remedies, § 42, p. 61, it was said: “Where the petition is not sufficient to warrant discharge, the writ should be quashed.”
Although not assigned as error, the statement is made in relator’s brief that respondent did not produce relator’s body before the court, and that he had no notice that a motion to dissolve had been filed. The record heretofore quoted, which has the import of verity, belies that statement. In any event, as stated in Jackson v. Olson, supra: “It would have been a futile act to have produced the petitioner before the court, when it was apparent to the court that even if his charges were sustained, the court would be required to deny the writ.” The statement has application here because no writ *621should have been allowed, and, having been erroneously allowed, it should have been dissolved.
Clearly, plaintiff’s petition contained no allegations which if admitted could by any construction lawfully justify his discharge from custody.
The judgment of the trial court should be and hereby is affirmed.
Affirmed.