Arthur Radley wrote:
> LFS 7.5-rc1 6.2.3. Mounting Virtual Kernel File Systems
>
> Re: mkdir -pv $LFS/$(readlink $LFS/dev/shm)
>
> If the host's /dev/shm is a symbolic link to /run/shm, then "readlink
> $LFS/dev/shm" will output "/run/shm". mkdir apparently ignores the extra
> forward slash and creates the directory, but the verbose output of mkdir
> will be "/mnt/lfs//run/shm" which looks wrong to anyone reading the verbose
> output (me).
>
> It's trivial. Anyway.
>
> P.S.: All the other instances of readlink in the book produce
> "../<something>" and don't do this.

In this case, the link target is an absolute path.  If I change it to:

mkdir -pv ${LFS}$(readlink $LFS/dev/shm)

it works.  It won't work if the target is a relative path (but I don't 
know of any systems that do that).  To make it work in all possible 
cases, then an ugly 2nd if or sed statement is needed to ensure there 
path is correct.  For example:

mkdir -pv $LFS/$(readlink $LFS/dev/shm | sed s:^/:: )

And then the construct needs to be explained.

Since the system doesn't distinguish between one or two slashes, should 
we really change this?

   -- Bruce

-- 
http://linuxfromscratch.org/mailman/listinfo/lfs-dev
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page

Reply via email to