mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Export all variables assigned to while allexport is on (#431)
All variables that are assigned a value should be exported while the allexport shell option is enabled. This works in most cases, but variables assigned to with ${var:=foo} or $((var=123)) aren't exported while allexport is on. src/cmd/ksh93/sh/name.c: - nv_putval(): This is the central assignment function; all forms of variable assignment end up here. So this is the best place to check for SH_ALLEXPORT and turn on the export attribute. - nv_setlist(): Remove allexport handling, now redundant. src/cmd/ksh93/bltins/read.c: sh_readline(): - Remove allexport handling, now redundant. src/cmd/ksh93/sh/main.c: sh_main(): - nv_putval() is used to initialize PS4 and IFS using nv_putval(); this is after an -a/--allexport specified on the ksh command line has been processed, so temporarily turn that off. Co-authored-by: Martijn Dekker <martijn@inlv.org>
This commit is contained in:
parent
0863a8eb29
commit
8e72608c1c
9 changed files with 85 additions and 17 deletions
|
@ -142,8 +142,6 @@ int sh_main(int ac, char *av[], Shinit_f userinit)
|
|||
}
|
||||
sh.fn_depth = sh.dot_depth = 0;
|
||||
command = error_info.id;
|
||||
if(nv_isnull(PS4NOD))
|
||||
nv_putval(PS4NOD,e_traceprompt,NV_RDONLY);
|
||||
path_pwd();
|
||||
iop = (Sfio_t*)0;
|
||||
if(sh_isoption(SH_POSIX))
|
||||
|
@ -358,7 +356,15 @@ int sh_main(int ac, char *av[], Shinit_f userinit)
|
|||
sh_onoption(SH_EMACS);
|
||||
#endif /* SHOPT_ESH */
|
||||
}
|
||||
/* (Re)set PS4 and IFS, but don't export these now even if allexport is on. */
|
||||
i = (sh_isoption(SH_ALLEXPORT) != 0);
|
||||
sh_offoption(SH_ALLEXPORT);
|
||||
if(nv_isnull(PS4NOD))
|
||||
nv_putval(PS4NOD,e_traceprompt,NV_RDONLY);
|
||||
nv_putval(IFSNOD,(char*)e_sptbnl,NV_RDONLY);
|
||||
if(i)
|
||||
sh_onoption(SH_ALLEXPORT);
|
||||
/* Start main execution loop. */
|
||||
exfile(iop,fdin);
|
||||
sh_done(0);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue