Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 10 Apr 2002 09:13:18 +0200 (CEST)
From:      Bogdan TARU <bgd@icomag.de>
To:        <freebsd-hackers@FreeBSD.ORG>
Subject:   'rm' incompatibility with Posix.2
Message-ID:  <20020410091302.Y79904-200000@fw.cgn.icom>

next in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]

	Hi everyone,

 I have noticed quite some time ago a strange way in which some basic
FreeBSD utilities work, related to symlinks. Example session:


bgd@cvs$ mkdir temp
bgd@cvs$ ln -s temp b
bgd@cvs$ ls -ald temp b
lrwxr-xr-x  1 bgd  wheel    4 Apr  9 11:27 b -> temp
drwxr-xr-x  2 bgd  wheel  512 Apr  9 11:27 temp
bgd@cvs$ rm -rf b/
bgd@cvs$ ls -ald temp b
ls: temp: No such file or directory
lrwxr-xr-x  1 bgd  wheel  4 Apr  9 11:27 b -> temp
bgd@cvs$


 As you can see, when I tried to remove the symlink 'b' with a trailing
slash 'rm -rf b/', the target directory was removed instead of the actual
symlink. Of course, this is weird (tryied it on some other 10 un*xes, and
all worked in another way).

 I have attached a patch for the 'rm' untility, which strips the trailing
slash(es) from the path (according to Posix.2). But I think there are many
other utilities which need to be patched (e.g. cp, mv).

 Greetings,
 bogdan

[-- Attachment #2 --]
0a1,2
> 
> 
463,470d464
<                 /* strip trailing slashes, since POSIX.2 defines basename
< 		   as the final portion of a path after the trailing slashes
< 		   have been removed.
< 		 */
<                 p = strrchr (*t, '\0');
<                 while (--p > *t && *p == '/')
<                        *p = '\0';
< 

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020410091302.Y79904-200000>