
58 Ill.2d 91 (1974)
316 N.E.2d 769
THE PEOPLE ex rel. JAMES MORRISON, Petitioner,
v.
ALLYN R. SIELAFF, Director, Illinois Department of Corrections, Respondent.
No. 46486.
Supreme Court of Illinois.
Opinion filed September 17, 1974.
Paul Bradley, State Appellate Defender, of Chicago (Steven Clark, Assistant Appellate Defender, of counsel), for petitioner.
William J. Scott, Attorney General, of Springfield (James B. Zagel and Nolan Lipsky, Assistant Attorneys General, of counsel), for respondent.
Writ denied.
MR. JUSTICE KLUCZYNSKI delivered the opinion of the court:
We granted the motion of petitioner James Morrison for leave to file an original action. (50 Ill.2d R. 381.) Petitioner seeks a writ of mandamus to compel respondent Allyn R. Sielaff, Director of the Illinois Department of Corrections, to credit against his penitentiary sentence the period he was "in custody" while on bail as set forth in section 5-8-7(b) of article 8 of chapter V of the Unified Code of Corrections. Ill. Rev. Stat. 1973, ch. 38, par. 1005-8-7(b).
*92 The issue presented for consideration is the interpretation of the term "custody" as used in section 5-8-7(b), which provides:
"The offender shall be given credit on the maximum term and the minimum period of imprisonment for time spent in custody as a result of the offense for which the sentence was imposed."
Petitioner asserts that he was arrested on July 24, 1972, and shortly thereafter released on bail. On December 14, 1972, he was incarcerated and ultimately sentenced to a term of one to three years in prison following his conviction for attempted theft by deception. He seeks to have the period of nearly five months when he was released on bail applied as a sentence credit.
Petitioner relies on several Federal decisions to support his contention that the term "custody" should be broadly construed to include circumstances other than incarceration, such as bail. (Hensley v. Municipal Court (1973), 411 U.S. 345, 36 L.Ed.2d 294, 93 S.Ct. 1571; United States v. Rudinsky (6th Cir.1971), 439 F.2d 1074.) These cases, and others cited by petitioner, considered the term "custody" in the context of either the Federal habeas corpus provisions (28 U.S.C. secs. 2241-2255) or the Federal escape law (18 U.S.C. sec. 751), and they are not controlling authority in the construction of the statutory provision presently at issue. Moreover, as noted in Hensley the purpose of the Federal habeas corpus provisions is to provide "a remedy for severe restraints on individual liberty." (411 U.S. at 351, 36 L.Ed.2d at 300; see also Harris v. Nelson, 394 U.S. 286, 291, 22 L.Ed.2d 281, 286, 89 S.Ct. 1082.) Therefore interpreting "custody" in a broader sense would be consistent with that statute. It is of further interest that in Rudinsky the defendant, who was charged with escape from a treatment center, sought to engraft a restrictive meaning on the term "custody" which seems in direct contrast to that of *93 petitioner. See also Murphy v. United States (8th Cir.1973), 481 F.2d 57, 61.
The term "custody" has been defined as actual imprisonment, or it has been adapted to include lesser restraints. (Black's Law Dictionary (4th ed. 1951) 460.) In cases involving substantially distinguishable issues from that presented herein, the term "custody" has been applied in the context urged by petitioner (People ex rel. Johnson v. Pate, 47 Ill.2d 172, 174 (parole)) or has been used in a manner consistent with respondent's contention that the term means confinement (People v. Anderson, 53 Ill.2d 437, 442; People v. Mikrut, 117 Ill. App.2d 444, 448 (speedy trial)). The Unified Code of Corrections does not specifically define the meaning of "custody."
The primary function in construing a statute is to give effect to the intent of the legislature. (People v. Scott, 57 Ill.2d 353, 358; People v. Wallace, 57 Ill.2d 285, 289-90.) In Wallace we reiterated the views that the entire statute must be considered in ascertaining this intent and that commentary related thereto may be a useful source in discerning this intent. When these criteria are applied in the present case, we must reject petitioner's contention.
Article 8 of chapter V of the Unified Code of Corrections contains several provisions in which the term "custody" necessarily must be construed as relating to confinement. Section 5-8-2(a) permits the trial court to impose a greater maximum period of "custody" under certain circumstances than that normally permitted for particular crimes. Section 5-8-5 speaks, in part, of delivering a defendant to the "custody" of the proper authority after a sentence of imprisonment has been imposed. Similarly, subparagraphs (b) and (e) of section 5-8-6, which concerns the place of confinement, support respondent's contention that "custody" is equivalent to confinement. Ill. Rev. Stat. 1973, ch. 38, pars. 1005-8-2(a), 1005-8-5, 1005-8-6(b) and (e).
*94 Further, bail is defined as the security necessary to release a person from "custody." (Ill. Rev. Stat. 1973, ch. 38, pars. 102-6 and 110-7(b).) If a person forfeits his bond, he shall not be bailable on the same felony charge after he is subsequently taken into "custody" unless the court makes the requisite determination as set forth in the statute. (Ill. Rev. Stat. 1973, ch. 38, par. 110-16.) These provisions demonstrate that the terms "custody" and "bail" are not used synonymously.
The predecessor to section 5-8-7 was section 119-3 of the Code of Criminal Procedure (Ill. Rev. Stat. 1971, ch. 38, par. 119-3). Section 119-3 explicitly provided that a defendant who received a sentence of incarceration was to gain sentence credit for any period during which he was confined for that offense. While more precise language might have been used in section 5-8-7, it does not appear that the intent expressed in section 119-3 was modified by section 5-8-7.
This conclusion is supported by the commentary to section 5-8-7 which is adverse to petitioner's position.
"This section * * * gives full credit for time served in custody as a result of the offense for which the sentence was imposed. This would apply irrespective of where the offender was confined and would apply to custody outside of the State." S.H.A. (1973), ch. 38, par. 1005-8-7, Council Commentary, p. 514. (Emphasis added.)
It is clear that this explication evinces the intent that "custody" does not include the period of time during which the defendant was released on bail but is predicated upon his confinement.
Writ denied.
