Skip to main content

setunderscore

Function setunderscore 

Source
pub fn setunderscore(str: &str)
Expand description

Port of void setunderscore(char *str) from Src/exec.c:2652.

C body:

queue_signals();
if (str && *str) {
    size_t l = strlen(str) + 1, nl = (l + 31) & ~31;
    if (nl > underscorelen || (underscorelen - nl) > 64) {
        zfree(zunderscore, underscorelen);
        zunderscore = (char *) zalloc(underscorelen = nl);
    }
    strcpy(zunderscore, str);
    underscoreused = l;
} else {
    ... reset zunderscore = "" ...
}
unqueue_signals();

Sets the $_ global to the last argument of the most recent command. Called from execcmd_exec (c:3936) per last_status update; mirrored in zshrs by the fusevm Op::Exec handler.