g_find_program_in_path not returning an absolute path
Description:
The documentation states, that g_find_program_in_path
should return an absolute path.
However, this is not the case if the PATH variable includes a relative path entry to the executable.
Tested versions showing the problem:
- 2.70.2
- 2.71.0 / main branch
Reproducer:
$ cat ./glib2_test_g_find_program_in_path.c
#include <stdio.h>
#include <glib.h>
int main( void ) {
char program[] = "foo";
printf("glib version %d.%d.%d\n",
glib_major_version, glib_minor_version, glib_micro_version);
char *abs_program = g_find_program_in_path(program);
char *cwd = g_get_current_dir ();
printf("Current dir: %s\n", cwd);
printf("%s -> %s\n", program, abs_program);
return 0;
}
$ mkdir mybin
$ touch mybin/foo
$ chmod +x mybin/foo
$ PATH=mybin:$PATH ./glib2_test_g_find_program_in_path
glib version 2.71.0
Current dir: /tmp/glibtest
foo -> mybin/foo
Fix:
A fix for the problem can be found in Merge Request !2460 (merged)
Related References and Pull Requests
- Past report about documentation discrepancy: #957
- Fix that addressed a similar case for filenames including partial paths: !2127 (merged)
Edited by Christoph Niethammer