aboutsummaryrefslogtreecommitdiff
path: root/tests/programs/args.zc
blob: aac72ec7b6b221d7749850cd48cf01367b17ce1d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// the command line and the environment, as the host hands them over. argv[0]
// is the program path, and <eval> when the source came from stdin, so argc is
// 1 even with nothing on the command line. run through a shell with no extra
// arguments, which is how test.sh calls it, so the line is fixed.
include "src/lib/std.zc";

fn main() {
	put_n(argc); put_c(32); put_s(argv[0]);
	put_c(32); put_c(32); put_s(argv[argc - 1]);
	// envc counts every entry, envp holds NAME=value strings
	put_c(32); put_n(envc > 0);
	let hit = 0;
	for (int i = 0; i < envc; i++) if (eq_w(envp[i], "ZC_ARG_TEST=ok")) hit = 1;
	put_c(32); put_n(hit);
	return 0;
}