[Slackbuilds-users] broken symlink or owner

fourtysixandtwo fourtysixandtwo at sliderr.net
Sun Jun 7 03:56:17 UTC 2026


True.

What I like about cp -aL is being specific about it's operation...no assumption.

On Sat, Jun 6, 2026 at 9:06 PM B. Watson <urchlay at slackware.uk> wrote:
>
>
>
> On Sat, 6 Jun 2026, fourtysixandtwo wrote:
>
> > "cp -aL" would also fix the problem...dereference the link.
>
> Just using cp (with no flags) generally would do the same.
>
> <root at xiphos:~># mkdir a
> <root at xiphos:~># cd a
> <root at xiphos:~/a># touch a
> <root at xiphos:~/a># ln -s a b
> <root at xiphos:~/a># ls -l
> total 0
> -rw-r--r-- 1 root root 0 Jun  6 22:53 a
> lrwxrwxrwx 1 root root 1 Jun  6 22:53 b -> a
> <root at xiphos:~/a># cp b c
> <root at xiphos:~/a># ls -l c
> -rw-r--r-- 1 root root 0 Jun  6 22:54 c
>
> "c" ends up a regular file, not a symlink.
>
> <root at xiphos:~/a># cp -a b d
> <root at xiphos:~/a># ls -l d
> lrwxrwxrwx 1 root root 1 Jun  6 22:53 d -> a
>
> ...with "cp -a", the destination ends up being a symlink.
>
> The intent of using "cp -a" is to preserve the timestamp, I suppose. But
> "cat $CWD/file > $PKG/path/file" doesn't preserve the timestamp either.
> Six of one, half a dozen of the other.
>
> So the rule should be: do not use "cp -a" to copy files from $CWD into
> $PKG. Not only does it risk creating broken symlinks, but your script
> doesn't know for a fact that root is the owner of the files in $CWD,
> and shouldn't make that assumption.
> _______________________________________________
> SlackBuilds-users mailing list
> SlackBuilds-users at slackbuilds.org
> https://lists.slackbuilds.org/mailman/listinfo/slackbuilds-users
> Archives - https://lists.slackbuilds.org/pipermail/slackbuilds-users/
> FAQ - https://slackbuilds.org/faq/
>


-- 
_______________________________________________
SlackBuilds-users mailing list
SlackBuilds-users at slackbuilds.org
https://lists.slackbuilds.org/mailman/listinfo/slackbuilds-users
Archives - https://lists.slackbuilds.org/pipermail/slackbuilds-users/
FAQ - https://slackbuilds.org/faq/


More information about the SlackBuilds-users mailing list