[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#13742: Is this soft link directory bug?
From: |
Bob Proulx |
Subject: |
bug#13742: Is this soft link directory bug? |
Date: |
Mon, 18 Feb 2013 11:18:20 -0700 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
tag 13742 + moreinfo notabug
close 13742
thanks
Taroe90 wrote:
> sorry for my poor english
Please do not worry. But there are questions.
> address@hidden:~/mywork/test/shell/ln/a$ ll
What is the "ll" command? And alias for "ls -l"? Or an alias for
"ls -lF"? Or something different?
> 总用量 8
> drwxrwxr-x 2 ping ping 4096 2月 18 11:23 ./
> drwxrwxr-x 3 ping ping 4096 2月 18 11:22 ../
> address@hidden:~/mywork/test/shell/ln/a$ ln -fs
> /home/ping/mywork/test/shell/ln/a /home/ping/mywork/test/shell/ln/b
What is the value of /home/ping/mywork/test/shell/ln/b before this
command?
If /home/ping/mywork/test/shell/ln/b does not exist then this will
create a symlink.
If /home/ping/mywork/test/shell/ln/b is a directory then it will
create a symlink within the target directory.
If /home/ping/mywork/test/shell/ln/b is itself already a symink then
if it already points to an existing directory then it will create a
new symlink within the existing directory.
If /home/ping/mywork/test/shell/ln/b exists then an error message will
be produce saying that the file exists and the command will exit non-zero.
> address@hidden:~/mywork/test/shell/ln/a$ ll
> 总用量 8
> drwxrwxr-x 2 ping ping 4096 2月 18 11:23 ./
> drwxrwxr-x 3 ping ping 4096 2月 18 11:22 ../
> lrwxrwxrwx 1 ping ping 33 2月 18 11:23 a -> /home/ping/mywork/test/shell/ln/a/
The above symlink value ends with a trailing "/". The "ll" command is
not known. If it is "ls -lF" then the trailing slash is produced by
the -F part. If not then it is part of the value. And if so then the
above "a" symlink was not produced by the previous "ln" command shown
but was created using a different command.
It is no problem to have /home/ping/mywork/test/shell/ln/a/a be a
symlink to /home/ping/mywork/test/shell/ln/a. This is allowed.
It is no problem to have /home/ping/mywork/test/shell/ln/a/a be a
symlink to /home/ping/mywork/test/shell/ln/a/. This is allowed. The
trailing slash forces the value to be interpreted as a directory.
> address@hidden:~/mywork/test/shell/ln/a$ cd ..
> address@hidden:~/mywork/test/shell/ln$ ll
> 总用量 12
> drwxrwxr-x 3 ping ping 4096 2月 18 11:22 ./
> drwxr-xr-x 9 ping ping 4096 2月 18 10:57 ../
> drwxrwxr-x 2 ping ping 4096 2月 18 11:23 a/
> lrwxrwxrwx 1 ping ping 33 2月 18 11:22 b -> /home/ping/mywork/test/shell/ln/a/
The "b" symlink points to "a". Creating a new symlink with a target
directory of "b" will follow the symlink into the "a" directory.
Simpler with shorter paths.
$ mkdir a
$ ln -s a b # <-- Creates "b" symink to "a"
$ ln -s a b # <-- Creates "a/a" symlink due to existence of "b"
To avoid using portable syntax. (Okay for System V systems [HP-UX, others].)
$ mkdir a
$ ln -s a b # <-- Creates "b" symink to "a"
$ rm -f b # <-- Removes "b" before creating second symlink
$ ln -s a b # <-- Creates "a/a" symlink due to existence of "b"
To avoid using BSD or GNU specific syntax.
$ mkdir a
$ ln -s a b # <-- Creates "b" symink to "a"
$ ln -sfn a b # <-- Creates "b" ignoring existing, ignoring symlink
> Why in a directory will appear a soft link?
> using absolute path.
It will appear because the existing symlink points to an existing
directory.
Please see the -n option. Here is the documentation from the ln command.
`-n'
`--no-dereference'
Do not treat the last operand specially when it is a symbolic link
to a directory. Instead, treat it as if it were a normal file.
When the destination is an actual directory (not a symlink to one),
there is no ambiguity. The link is created in that directory.
But when the specified destination is a symlink to a directory,
there are two ways to treat the user's request. `ln' can treat
the destination just as it would a normal directory and create the
link in it. On the other hand, the destination can be viewed as a
non-directory--as the symlink itself. In that case, `ln' must
delete or backup that symlink before creating the new link. The
default is to treat a destination that is a symlink to a directory
just like a directory.
This option is weaker than the `--no-target-directory' (`-T')
option, so it has no effect if both options are given.
Bob