Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 286191 | Differences between
and this patch

Collapse All | Expand All

(-)python-wrapper.c (-8 / +12 lines)
Lines 156-162 Link Here
156
	{
156
	{
157
		return NULL;
157
		return NULL;
158
	}
158
	}
159
	/* walk backwards through the list */
159
	/* Walk backwards through the list. */
160
	while (n--)
160
	while (n--)
161
	{
161
	{
162
		if (! ret)
162
		if (! ret)
Lines 167-173 Link Here
167
	return ret;
167
	return ret;
168
}
168
}
169
169
170
int main(__attribute__((unused)) int argc, char** argv)
170
int main(int argc, char** argv)
171
{
171
{
172
	if (strlen(program_description) == 0)
172
	if (strlen(program_description) == 0)
173
		abort();
173
		abort();
Lines 199-218 Link Here
199
199
200
	if (strchr(EPYTHON, '/'))
200
	if (strchr(EPYTHON, '/'))
201
	{
201
	{
202
		argv[0] = (char*) EPYTHON;
202
		fprintf(stderr, "Invalid value of EPYTHON variable or invalid configuration of Python wrapper\n");
203
		execv(EPYTHON, argv);
204
		return EXIT_ERROR;
203
		return EXIT_ERROR;
205
	}
204
	}
206
205
206
	/* Update argv[0], if a script with a Python shebang is probably being executed.
207
	 * argv[0] can be "python", when "#!/usr/bin/env python" shebang is used. */
208
	if (argc >= 2 && (argv[0][0] == '/' || strcmp(argv[0], "python") == 0) && argv[1][0] == '/')
209
		argv[0] = argv[1];
210
	else if (argc >= 3 && argv[0][0] == '/' && argv[1][0] == '-' && argv[2][0] == '/')
211
		argv[0] = argv[2];
212
207
	const char* path = find_path(argv[0]);
213
	const char* path = find_path(argv[0]);
208
	if (*path)
214
	if (path)
209
	{
215
	{
210
		argv[0] = dir_cat(path, EPYTHON);
216
		execv(dir_cat(path, EPYTHON), argv);
211
		execv(argv[0], argv);
212
		/* If this failed, then just search the PATH. */
217
		/* If this failed, then just search the PATH. */
213
	}
218
	}
214
219
215
	argv[0] = (char*) EPYTHON;
216
	execvp(EPYTHON, argv);
220
	execvp(EPYTHON, argv);
217
	return EXIT_ERROR;
221
	return EXIT_ERROR;
218
}
222
}

Return to bug 286191