A quirk in the "cp" command (relative vs full paths)

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
s243a
Posts: 2580
Joined: Tue 02 Sep 2014, 04:48
Contact:

A quirk in the "cp" command (relative vs full paths)

#1 Post by s243a »

I noticed an inconsistency in the cp command syntax. The following with relative paths doesn't work:

Code: Select all

cp -arfv --remove-destination "ppm-mod-3.0_patch"/* ppm-mod-3.0
because it creates a directory called ppm-mod-3.0_patch inside ppm-mod-3.0, when what I was trying to do was merge.

The workaround is to either cd into ppm-mod-3.0_patch folder and do the following:

Code: Select all

cp -arfv --remove-destination * ../ppm-mod-3.0
I think that "./*" would do the same as "*" here, or alternatively use the full path of each folder in the original path. What I think is odd here is how the behavior of "cp" changes if you use relative paths vs full paths but I think that I'm missing some design philosophy here in linux like systems.
Find me on [url=https://www.minds.com/ns_tidder]minds[/url] and on [url=https://www.pearltrees.com/s243a/puppy-linux/id12399810]pearltrees[/url].

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

Re: A quirk in the "cp" command (relative vs full paths)

#2 Post by MochiMoppel »

s243a wrote:The following with relative paths doesn't work
Works perfectly for me. Copies contents of the source directory, not the directory itself.
Full paths or relaive paths make no difference. No quirks, no inconsistencies.

Post Reply