cp on linux is part of gnu coreutils (http://www.gnu.org/software/coreutils/)
the error can be found in /coreutils-6.9/tests/cp/into-self

So it is not a part of bash or ksh (also on OpenBSD it is not part of the 
shell, the code is in /usr/src/bin/cp/).



>> I beat you to trying it on Linux
>
>No I didn't. Others beat me and you to it. Apologies for the unnecessary noise.
>
>(...)
>
>> IMHO cp behaving like this is somewhat nicer than its current
>> behaviour on apparently most or all BSD OSes.
>
>I'm surprised now.
>
>I just thought that what I wrote above was stupid, because I thought
>that the behaviour of cp was a function of the shell built-in command
>cp, not of the OS.
>To confirm this, I installed the OpenBSD default shell pdksh on
>Ubuntu. However, pdksh on Ubuntu gives the same result as bash on
>Ubuntu. So is this a function of the OS after all?
>
>| [EMAIL PROTECTED]:~$ uname -a
>| Linux tranquility 2.6.22-14-386 #1 Sun Oct 14 22:36:54 GMT 2007 i686 
>GNU/Linux
>| [EMAIL PROTECTED]:~$ echo $SHELL
>| /bin/bash
>
>We're on Linux and we're using bash.
>
>| [EMAIL PROTECTED]:~$ mkdir foo
>| [EMAIL PROTECTED]:~$ cp -r foo foo
>| cp: cannot copy a directory, `foo', into itself, `foo/foo'
>
>Bash behaves as expected.
>
>| [EMAIL PROTECTED]:~$ sudo apt-get install pdksh
>| Reading package lists... Done
>| Building dependency tree
>| Reading state information... Done
>| The following NEW packages will be installed:
>|   pdksh
>| 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
>| Need to get 0B/261kB of archives.
>| After unpacking 442kB of additional disk space will be used.
>| Selecting previously deselected package pdksh.
>| (Reading database ... 167230 files and directories currently installed.)
>| Unpacking pdksh (from .../pdksh_5.2.14-20build1_i386.deb) ...
>| Setting up pdksh (5.2.14-20build1) ...
>
>Ok, now pdksh is installed.
>
>| [EMAIL PROTECTED]:~$ pdksh
>| $ ps | grep sh
>|  6567 pts/0    00:00:00 bash
>|  6816 pts/0    00:00:00 pdksh
>|  6818 pts/0    00:00:00 pdksh
>
>Now we're running pdksh (echo $SHELL isn't changed when launching
>another shell interactively, hence the use of ps to confirm).
>
>| $ rm -rf foo
>
>Need to rm foo to start from scratch.
>
>| $ mkdir foo
>| $ cp -r foo foo
>| cp: cannot copy a directory, `foo', into itself, `foo/foo'
>
>Strange.
>
>pdksh on Linux behaves just like bash on Linux, and unlike pdksh on OpenBSD.
>I didn't expect that. So does that error message depend on OS APIs
>rather than the shell program and its built-in commands?

Reply via email to