pub fn cancd2(s: &str) -> i32Expand description
Port of static int cancd2(char *s) from Src/exec.c:6411.
C body:
struct stat buf;
char *us, *us2 = NULL;
int ret;
if (!isset(CHASEDOTS) && !isset(CHASELINKS)) {
if (*s != '/')
us = tricat(pwd[1] ? pwd : "", "/", s);
else
us = ztrdup(s);
fixdir(us2 = us);
} else
us = unmeta(s);
ret = !(access(us, X_OK) || stat(us, &buf) || !S_ISDIR(buf.st_mode));
if (us2) free(us2);
return ret;True iff s is a directory we can cd into (X-perm). With
!CHASEDOTS && !CHASELINKS, lexically canonicalise the path
(joining with PWD if relative) so cd /foo/bar/.. works without
resolving the symlink. Otherwise pass s through unmeta to libc.