[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] [Chicken-hackers] CHICKEN 4.9.0rc1 is available
From: |
John Cowan |
Subject: |
Re: [Chicken-users] [Chicken-hackers] CHICKEN 4.9.0rc1 is available |
Date: |
Tue, 6 May 2014 10:38:03 -0400 |
User-agent: |
Mutt/1.5.20 (2009-06-14) |
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 address@hidden
There are three kinds of people in the world:
those who can count, and those who can't.
- Re: [Chicken-users] CHICKEN 4.9.0rc1 is available, Michele La Monaca, 2014/05/04
- Re: [Chicken-users] CHICKEN 4.9.0rc1 is available, Peter Bex, 2014/05/05
- Re: [Chicken-users] CHICKEN 4.9.0rc1 is available, Michele La Monaca, 2014/05/06
- Re: [Chicken-users] [Chicken-hackers] CHICKEN 4.9.0rc1 is available, Mario Domenech Goulart, 2014/05/06
- Re: [Chicken-users] [Chicken-hackers] CHICKEN 4.9.0rc1 is available,
John Cowan <=
- Re: [Chicken-users] [Chicken-hackers] CHICKEN 4.9.0rc1 is available, Michele La Monaca, 2014/05/06
- Re: [Chicken-users] [Chicken-hackers] CHICKEN 4.9.0rc1 is available, Mario Domenech Goulart, 2014/05/06
- Re: [Chicken-users] [Chicken-hackers] CHICKEN 4.9.0rc1 is available, Peter Bex, 2014/05/07
- Re: [Chicken-users] [Chicken-hackers] CHICKEN 4.9.0rc1 is available, Michele La Monaca, 2014/05/07
- Re: [Chicken-users] [Chicken-hackers] CHICKEN 4.9.0rc1 is available, Peter Bex, 2014/05/08