Mario Domenech Goulart scripsit: > Getting the current work directory is surprisingly hard (maybe not that > surprising). There's $PWD, the pwd shell builtin and the pwd executable > file (usually /bin/pwd or /usr/bin/pwd).
You can't count on the shell built-in existing; it's a bashism. As for /bin/pwd, it turns out it has options: /bin/pwd -L does sanity checks on $PWD and outputs it if it looks sane (if not, it falls back to its internal algorithm), whereas /bin/pwd -P ignores $PWD. The default is -L. I doubt if one Unix programmer in ten thousand knows about these. Some Unixes have a syscall to retrieve the current directory. If not, the canonical algorithm is to stat "." to find out its device number and i-number, and then cd to ".." and search the new current directory for a name whose i-number matches the one we had before. Repeat until we reach the root (i-number 2). -- John Cowan http://www.ccil.org/~cowan co...@ccil.org There are three kinds of people in the world: those who can count, and those who can't. _______________________________________________ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users