unix:getenv, unix:chdir

FossilOrigin-Name: 59da938df20d3bf9fc7b72184e2ae6dd3f971f20f40c3d245e9cf2201d967cb4
This commit is contained in:
crc 2017-11-10 19:10:33 +00:00
parent c2005b0ea6
commit c9aa72a25d
3 changed files with 12 additions and 2 deletions

File diff suppressed because one or more lines are too long

View file

@ -321,6 +321,8 @@ void update_rx() {
#define UNIX_POPEN -8010 #define UNIX_POPEN -8010
#define UNIX_PCLOSE -8011 #define UNIX_PCLOSE -8011
#define UNIX_WRITE -8012 #define UNIX_WRITE -8012
#define UNIX_CHDIR -8013
#define UNIX_GETENV -8014
CELL unixOpenPipe() { CELL unixOpenPipe() {
CELL slot, mode, name; CELL slot, mode, name;
@ -419,6 +421,12 @@ void execute(int cell) {
a = stack_pop(); a = stack_pop();
write(fileno(ioFileHandles[c]), string_extract(a), b); write(fileno(ioFileHandles[c]), string_extract(a), b);
break; break;
case UNIX_CHDIR: chdir(string_extract(stack_pop()));
break;
case UNIX_GETENV: a = stack_pop();
b = stack_pop();
string_inject(getenv(string_extract(b)), a);
break;
default: printf("Invalid instruction!\n"); default: printf("Invalid instruction!\n");
printf("At %d, opcode %d\n", ip, opcode); printf("At %d, opcode %d\n", ip, opcode);
exit(1); exit(1);

View file

@ -141,6 +141,8 @@ to send.
~~~ ~~~
:unix:write (sh-) [ dup s:length ] dip `-8012 ; :unix:write (sh-) [ dup s:length ] dip `-8012 ;
:unix:chdir (s-) `-8013 ;
:unix:getenv (sa-) `-8014 ;
~~~ ~~~
--------------------------------------------------------------- ---------------------------------------------------------------