Skip to content

Commit 0791b4c

Browse files
committed
clean ups
1 parent 4842cd5 commit 0791b4c

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

Diff for: src/module/os.c

+6-13
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ static void processOnExit(uv_process_t* req, int64_t exit_status, int term_signa
164164
{
165165
free(env);
166166
index += 1;
167-
env = data->options.args[index];
167+
env = data->options.env[index];
168168
}
169169
}
170170

@@ -200,30 +200,20 @@ void processExec(WrenVM* vm)
200200
if (wrenGetSlotType(vm, 4) == WREN_TYPE_NULL) {
201201
// no environment specified
202202
} else if (wrenGetSlotType(vm, 4) == WREN_TYPE_LIST) {
203-
// fprintf(stderr,"got list\n");
204203
int envCount = wrenGetListCount(vm, 4);
205204
int envSize = sizeof(char*) * (envCount + 1);
206205

207206
data->options.env = (char**)malloc(envSize);
208207
data->options.env[envCount] = NULL;
209208

210-
// fprintf(stderr,"envsize %d\n", envCount);
211209
for (int i = 0; i < envCount ; i++)
212210
{
213-
214211
wrenGetListElement(vm, 4, i, 6);
215212
if (wrenGetSlotType(vm, 6) != WREN_TYPE_STRING) {
216-
wrenSetSlotString(vm, 0, "arguments to env are supposed to be string");
213+
wrenSetSlotString(vm, 0, "arguments to env are supposed to be strings");
217214
wrenAbortFiber(vm, 0);
218215
}
219216
char* envKeyPlusValue = cli_strdup(wrenGetSlotString(vm, 6));
220-
// fprintf(stderr,"key: %s\n", envKeyPlusValue);
221-
// fprintf(stderr,"setting %s\n", envKeyPlusValue);
222-
// char* equalSplit = strchr(envKeyPlusValue, '=');
223-
// *equalSplit = '\0';
224-
// char* key = envKeyPlusValue;
225-
// char* value = equalSplit + 1;
226-
227217
data->options.env[i] = envKeyPlusValue;
228218
}
229219
}
@@ -239,7 +229,10 @@ void processExec(WrenVM* vm)
239229
for (int i = 0; i < argCount; i++)
240230
{
241231
wrenGetListElement(vm, 2, i, 3);
242-
//:todo: ensure this is a string, and report an error if not
232+
if (wrenGetSlotType(vm, 3) != WREN_TYPE_STRING) {
233+
wrenSetSlotString(vm, 0, "arguments to args are supposed to be strings");
234+
wrenAbortFiber(vm, 0);
235+
}
243236
char* arg = cli_strdup(wrenGetSlotString(vm, 3));
244237
data->options.args[i + 1] = arg;
245238
}

0 commit comments

Comments
 (0)