When a person for whose appearance a warrant or summons has been issued under the proviso to sub-section (3) of section 122, or under section 126, sub-section (2), appears or if brought before him, the Magistrate shall cancel the bond executed by such person and shall order such person to give, for the unexpired portion of the term of such bond...