[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::digital_unix

Title:DIGITAL UNIX(FORMERLY KNOWN AS DEC OSF/1)
Notice:Welcome to the Digital UNIX Conference
Moderator:SMURF::DENHAM
Created:Thu Mar 16 1995
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:10068
Total number of notes:35879

9273.0. "recursive directory copy (cp -r) differs to other UNIXes" by RDGENG::WOOD_J ([email protected]) Tue Mar 25 1997 04:39

It seems that Digital UNIX behaves differently to other UNIXes when recursively
copying directories. This is only apparent when the source directory being
copied from includes a slash "/" at the end.

For example, suppose on Digital UNIX I have the following directory hierachy 
for "main.dir":

    % pwd
    /usr/users/wood_j

    % ls -R main.dir
    file_in_main  sub.dir
    
    main.dir/sub.dir:
    file_in_sub
    %

If I copy the "main.dir" directory tree to a new directory tree of "copy.dir",
then doing "cp -r main.dir copy.dir" results in a new main.dir which is a
subdirectory of copy.dir:

    % mkdir copy.dir
    % cp -r main.dir copy.dir               ---(1)
    % ls -R copy.dir
    main.dir

    copy.dir/main.dir:
    file_in_main  sub.dir

    copy.dir/main.dir/sub.dir:
    file_in_sub
    % 

This is consistent with other UNIX systems. 

However, if the source directory in the copy command has a slash "/" appended,
then this is the result on Digital UNIX:

    % mkdir copy_slash.dir
    % cp -r main.dir/ copy_slash.dir        ---(2)
    % ls -R copy_slash.dir
    file_in_main  sub.dir

    copy_slash.dir/sub.dir:
    file_in_sub
    %

That is, the source directory (main.dir) is not copied into the target
directory (copy_slash.dir) as before, but the contents of main.dir are copied.
Apparently other UNIX versions (Solaris 2.x, HP-UX 9x and 10x, AIX 1.4.0,
and UNIX_SV 4.0) treat the second copy command the same as the first.

Is there a reason for Digital UNIX behaving differently? Is there a way to get
the second copy command to perform as the first copy command (-perhaps using
the System-V environment?).

T.RTitleUserPersonal
Name
DateLines
9273.1Re: recursive directory copy (cp -r) differs to other UNIXesQUABBI::"[email protected]"Tue Mar 25 1997 09:1316
[email protected] ([email protected]) writes:

>Title: recursive directory copy (cp -r) differs to other UNIXes

>That is, the source directory (main.dir) is not copied into the target
>directory (copy_slash.dir) as before, but the contents of main.dir are copied.
>Apparently other UNIX versions (Solaris 2.x, HP-UX 9x and 10x, AIX 1.4.0,
>and UNIX_SV 4.0) treat the second copy command the same as the first.

Smells like a bug to me and worth a QAR.  Supporting that "slash on the end"
style name is a royal pain in the butt that introduced glitches all over
the place.
-- 
  <>    Eric (Ric) Werme   <>      This space under reconstruction       <>
  <>  <[email protected]>  <>                                            <>
[posted by Notes-News gateway]
9273.2QAR 52182 on GORGE::RDGENG::WOOD_J[email protected]Wed Mar 26 1997 03:440