* [9fans] plan9ports, mk, using rc as shell
@ 2004-04-27 15:57 Bengt Kleberg
0 siblings, 0 replies; only message in thread
From: Bengt Kleberg @ 2004-04-27 15:57 UTC (permalink / raw)
To: 9fans
[-- Attachment #1: Type: text/plain, Size: 231 bytes --]
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;
[-- Attachment #2: file.suspect --]
[-- Type: application/octet-stream, Size: 2947 bytes --]
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--
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2004-04-27 15:57 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-27 15:57 [9fans] plan9ports, mk, using rc as shell Bengt Kleberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).