Hi! > 2. Why do you feel this is required? Well, accordingly to POSIX you can't realy rely on having /bin/sh or even /usr/bin/sh. On the other hand I haven't seen any linux system that has no /bin/sh. And accordingly to FSH /bin/sh is required to exist. So this really depends on how much we want to be compatible with POSIX and strange unixes out there (if there are any).
* FSH http://www.pathname.com/fhs/ * POSIX http://www.opengroup.org/onlinepubs/000095399/utilities/sh.html (paragraph "application usage") > 3. This should really be a single snprintf call: > > + /* copy path */ > + for (i = 0; i < buf_len && path[i] != '\0' && path[i] != ':'; > i++) > + buf[i] = path[i]; > + > + /* add slash at the end if needed */ > + if (buf[i - 1] != '/') > + buf[i++] = '/'; > + /* copy the program name */ > + strncpy(buf + i, prog_name, buf_len - i); > > similar to the following: > > if (snprintf(buf, buf_len, "%s/%s", path_element, prog_name) > buf_len) > /* error out */ > else if (file_exist(buf)) > return 0; /* etc... */ > /* ... */ This way I would need either to copy the path element into temporary path_element[] array each time before snprintf is called or duplicate the string returned by getenv("PATH") so that I could insert '\0' in it. -- Cyril Hrubis [email protected] ------------------------------------------------------------------------------ _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
