1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-05-18 14:06:03 +02:00

51631: initialize $_ by copying it from environment

This commit is contained in:
Jun-ichi Takimoto 2023-04-09 20:44:58 +09:00
parent 98b4d4bdca
commit 8a9aea907a
3 changed files with 13 additions and 4 deletions

View File

@ -1,5 +1,8 @@
2023-04-09 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>
* 51631: Doc/Zsh/params.yo, Src/init.c: initialize $_ by copying
it from environment
* 51632: Src/exec.c: unmetafy $_ when exporting it to child
2023-04-03 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>

View File

@ -779,7 +779,10 @@ last pipeline.
)
vindex(_)
item(tt(_) <S>)(
The last argument of the previous command.
Initially, if tt(_) exists in the environment, then this parameter is set to
its value. This value may be the full pathname of the current zsh
executable or the script command file.
Later, this parameter is set to the last argument of the previous command.
Also, this parameter is set in the environment of every command
executed to the full pathname of the command.
)

View File

@ -1084,9 +1084,12 @@ setupvals(char *cmd, char *runscript, char *zsh_name)
ztrdup(DEFAULT_IFS_SH) : ztrdup(DEFAULT_IFS);
wordchars = ztrdup(DEFAULT_WORDCHARS);
postedit = ztrdup("");
zunderscore = (char *) zalloc(underscorelen = 32);
underscoreused = 1;
*zunderscore = '\0';
/* If _ is set in environment then initialize our $_ by copying it */
zunderscore = getenv("_");
zunderscore = zunderscore ? metafy(zunderscore, -1, META_DUP) : ztrdup("");
underscoreused = strlen(zunderscore) + 1;
underscorelen = (underscoreused + 31) & ~31;
zunderscore = (char *)zrealloc(zunderscore, underscorelen);
zoptarg = ztrdup("");
zoptind = 1;