Skip to content

cp: Do not trust st_size if it equals zero#24

Closed
ricardobranco777 wants to merge 1 commit into
NetBSD:trunkfrom
ricardobranco777:cp
Closed

cp: Do not trust st_size if it equals zero#24
ricardobranco777 wants to merge 1 commit into
NetBSD:trunkfrom
ricardobranco777:cp

Conversation

@ricardobranco777

Copy link
Copy Markdown

cp(1) cannot operate on files residing on pseudo-filesystems.

To reproduce:

$ cp /proc/mounts /tmp
$ ls -l /tmp/mounts
-r--r--r--  1 ricardo  wheel  0 Jan 14 19:30 /tmp/mounts

@ricardobranco777

Copy link
Copy Markdown
Author

Merged.

netbsd-srcmastr pushed a commit that referenced this pull request Sep 2, 2025
	bin/sh/cd.c: revision 1.54
	bin/sh/cd.c: revision 1.55
	bin/sh/cd.c: revision 1.56

PR standards/59565 - cd "" is now an error, not == cd .

POSIX 2024 requires that cd "" generate an error message,
and fail.

Until now shells (including this one) have typically equated
it to "cd ." as in the distant past, a lookup of "" as a path
name would return the current directory (aka ".").

From now on, we generate an error, as specified.
(For this commit, the error message is kind of pathetic,
but it is at least there - that will be fixed in a
subsequent commit.)


Improve error messages from cd builtin

Have cd indicate (particularly for when CDPATH is in use,
but also in other cases) which path name was attempted
and failed, and why it failed.   For CDPATH uses, when
(if) the cd eventually fails, prefer the first entry in
which the requested destination path is located (when
the chdir() to it fails), or if there is none of those,
the first lookup which failed to determine if the path
exists there or not (ie: not ENOENT).

If the all attempts return ENOENT simply report the arg
given (after "cd -" and "cd a b" processing), as no
one CDPATH entry is more appropriate than any other.

Inspired by PR standards/59565 but not directly related.


PR bin/59602  PWD update failure message from cd fix.
Only complain about being unable to determine the new
directory name after a cd when -e is given (test for
that was forgotten).
netbsd-srcmastr pushed a commit that referenced this pull request Sep 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant