From mboxrd@z Thu Jan 1 00:00:00 1970 To: 9fans@cse.psu.edu From: Bengt Kleberg Message-ID: Subject: [9fans] plan9ports, mk, using rc as shell Date: Tue, 27 Apr 2004 15:57:35 +0000 Content-Type: multipart/mixed; boundary="upas-bxcgpwzjltjcboiktvvbomynei" Content-Disposition: inline Topicbox-Message-UUID: 6f824b7e-eacd-11e9-9e20-41e7f4b1d025 This is a multi-part message in MIME format. --upas-bxcgpwzjltjcboiktvvbomynei Content-Disposition: inline Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit from postmaster@ethel: The following attachment had content that we can't prove to be harmless. To avoid possible automatic execution, we changed the content headers. The original header was: Content-Type: multipart/mixed; --upas-bxcgpwzjltjcboiktvvbomynei Content-Type: application/octet-stream Content-Disposition: attachment; filename="file.suspect" This is a multi-part message in MIME format. --------------070508010706030608020407 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit greetings, this is in case anybody is still thinking about the ''sh/rc in mk'' discussion some days ago. i added an environment variable MKSHELL_RC. if set to the full path of rc, mk will use rc to run recipes. note that assignments in the mkfile has not been changed. ie, VAR = `{echo *.c} still works. (yes, that does look like rc syntax, does it not? but it has ''always'' worked) and VAR = asd ^ 123 does not work. bengt --------------070508010706030608020407 Content-Type: text/plain; name="bfile" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="bfile" *** unix.c Sat Apr 24 07:03:27 2004 --- /home/eleberg/private/plan9/src/cmd/mk/unix.c Tue Apr 27 17:40:13 2004 *************** *** 16,21 **** --- 16,64 ---- fprint(2, "%s: %r\n", s); } + static void + choose_shell( char* args, int args_are_command ) { + char* mkshell; + char* mkshell_rc; + char* mkshell_name; + + /* if rc path is set, use it */ + mkshell_rc = getenv( "MKSHELL_RC" ) ; + if (mkshell_rc) { + mkshell = mkshell_rc; + mkshell_name = "rc"; + } else { + mkshell = shell; + mkshell_name = shellname; + } + if (args_are_command) { + if(shflags) + execl(mkshell, mkshell_name, shflags, "-c", args, 0); + else + execl(mkshell, mkshell_name, "-c", args, 0); + } else { + if(shflags) + execl(mkshell, mkshell_name, shflags, args, 0); + else + execl(mkshell, mkshell_name, args, 0); + } + mkperror(mkshell); + /* when using plan9 getenv() we need free() + if (mkshell_rc) + free(mkshell_rc); + */ + } + + static void + choose_execshell( char* args ) { + choose_shell( args, 0 ); + } + + static void + choose_pipeshell( char* cmd ) { + choose_shell( cmd, 1 ); + } + void readenv(void) { *************** *** 131,141 **** close(in[1]); if (e) exportenv(e); ! if(shflags) ! execl(shell, shellname, shflags, args, 0); ! else ! execl(shell, shellname, args, 0); ! mkperror(shell); _exit(1); } close(out[1]); --- 174,180 ---- close(in[1]); if (e) exportenv(e); ! choose_execshell( args ); _exit(1); } close(out[1]); *************** *** 196,206 **** } if(e) exportenv(e); ! if(shflags) ! execl(shell, shellname, shflags, "-c", cmd, 0); ! else ! execl(shell, shellname, "-c", cmd, 0); ! mkperror(shell); _exit(1); } if(fd){ --- 235,241 ---- } if(e) exportenv(e); ! choose_pipeshell( cmd ); _exit(1); } if(fd){ *************** *** 308,310 **** --- 343,346 ---- return st.st_mtime; } + --------------070508010706030608020407-- --upas-bxcgpwzjltjcboiktvvbomynei--