Mike Frysinger <vapier <at> gentoo.org> writes: > > cd /tmp > > mkdir -p sub > > { > > ln --at=4 -sf foo bar # call symlinkat("foo",4,"bar") > > readlink --at=4 -m bar # call areadlinkat(4,"bar") > > } 4< sub > > > > would output /tmp/sub/foo. > > isnt this possible today under linux by using /proc/self/fd ? i'm not > suggesting this as a clean/portable replacement, just trying to better > understand the proposal.
Yes, with sufficient /proc supprt, the above example would be equivalent to: cd /tmp mkdir -p sub { ln -sf foo /proc/self/4/bar readlink -m /proc/self/4/bar } 4< sub Without /proc, it's similar to doing everything via absolute or anchored paths (or using shell variables for shorthand), but then you lose time with O(n^2) on deep nesting of directories, as well as the robustness that the *at functions give in the case that some other process is modifying the same hierarchy that you are operating on: cd /tmp mkdir -p sub dir=sub { ln -sf foo "$dir"/bar readlink -m "$dir"/bar } 4< "$dir" > --at-fd might be a better explicit option without getting too verbose ? Indeed. -- Eric Blake