File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed
Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -1288,6 +1288,25 @@ static int shell_register_event_context (flux_shell_t *shell)
12881288 return 0 ;
12891289}
12901290
1291+ /* Export a static list of environment variables from the job environment
1292+ * to the current shell environment. This is important for variables like
1293+ * FLUX_F58_FORCE_ASCII which should influence some shell behavior.
1294+ */
1295+ static int shell_export_environment_from_job (flux_shell_t * shell )
1296+ {
1297+ const char * vars [] = {
1298+ "FLUX_F58_FORCE_ASCII" ,
1299+ NULL ,
1300+ };
1301+
1302+ for (int i = 0 ; vars [i ] != NULL ; i ++ ) {
1303+ const char * val = flux_shell_getenv (shell , vars [i ]);
1304+ if (val && setenv (vars [i ], val , 1 ) < 0 )
1305+ return shell_log_errno ("setenv (%s)" , vars [i ]);
1306+ }
1307+ return 0 ;
1308+ }
1309+
12911310int main (int argc , char * argv [])
12921311{
12931312 flux_shell_t shell ;
@@ -1325,6 +1344,9 @@ int main (int argc, char *argv[])
13251344 if (!(shell .info = shell_info_create (& shell )))
13261345 exit (1 );
13271346
1347+ if (shell_export_environment_from_job (& shell ) < 0 )
1348+ exit (1 );
1349+
13281350 if (shell_register_event_context (& shell ) < 0 )
13291351 shell_die (1 , "failed to add standard shell event context" );
13301352
Original file line number Diff line number Diff line change @@ -377,4 +377,13 @@ test_expect_success 'job-shell: -o nosetpgrp works' '
377377 flux mini run -n2 -o nosetpgrp \
378378 flux python -c "import os,sys; sys.exit(os.getpid() == os.getpgrp())"
379379'
380+
381+ # Check that job shell inherits FLUX_F58_FORCE_ASCII.
382+ # If not, then output filename will not match jobid returned by submit,
383+ # since one will be in UTF-8 and the other in ascii.
384+ test_expect_success ' job-shell: shell inherits FLUX_F58_FORCE_ASCII from job' '
385+ FLUX_F58_FORCE_ASCII=t \
386+ id=$(flux mini submit --wait --output={{id}}.out hostname) &&
387+ test -f ${id}.out
388+ '
380389test_done
You can’t perform that action at this time.
0 commit comments