mirror of
https://github.com/containers/podman.git
synced 2025-06-24 19:42:56 +08:00
podman cp: test /dev/stdin correctly
/dev/stdin should not be treated as "-" to remain compatible with Docker and to have a more consistent and idiomatic interface. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
This commit is contained in:
@ -231,8 +231,6 @@ func copyToContainer(container string, containerPath string, hostPath string) er
|
|||||||
if hostPath == "-" {
|
if hostPath == "-" {
|
||||||
hostPath = os.Stdin.Name()
|
hostPath = os.Stdin.Name()
|
||||||
isStdin = true
|
isStdin = true
|
||||||
} else if hostPath == os.Stdin.Name() {
|
|
||||||
isStdin = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure that host path exists.
|
// Make sure that host path exists.
|
||||||
|
@ -475,9 +475,9 @@ load helpers
|
|||||||
run_podman exec cpcontainer rm -rf /tmp/$srcdir
|
run_podman exec cpcontainer rm -rf /tmp/$srcdir
|
||||||
|
|
||||||
# Now for "/dev/stdin".
|
# Now for "/dev/stdin".
|
||||||
|
# Note: while this works, the content ends up in Nirvana.
|
||||||
|
# Same for Docker.
|
||||||
run_podman cp /dev/stdin cpcontainer:/tmp < $tar_file
|
run_podman cp /dev/stdin cpcontainer:/tmp < $tar_file
|
||||||
run_podman exec cpcontainer cat /tmp/$srcdir/$rand_filename
|
|
||||||
is "$output" "$rand_content"
|
|
||||||
|
|
||||||
# Error checks below ...
|
# Error checks below ...
|
||||||
|
|
||||||
@ -487,11 +487,11 @@ load helpers
|
|||||||
|
|
||||||
# Destination must be a directory (on an existing file).
|
# Destination must be a directory (on an existing file).
|
||||||
run_podman exec cpcontainer touch /tmp/file.txt
|
run_podman exec cpcontainer touch /tmp/file.txt
|
||||||
run_podman 125 cp /dev/stdin cpcontainer:/tmp/file.txt < $tar_file
|
run_podman 125 cp - cpcontainer:/tmp/file.txt < $tar_file
|
||||||
is "$output" 'Error: destination must be a directory when copying from stdin'
|
is "$output" 'Error: destination must be a directory when copying from stdin'
|
||||||
|
|
||||||
# Destination must be a directory (on an absent path).
|
# Destination must be a directory (on an absent path).
|
||||||
run_podman 125 cp /dev/stdin cpcontainer:/tmp/IdoNotExist < $tar_file
|
run_podman 125 cp - cpcontainer:/tmp/IdoNotExist < $tar_file
|
||||||
is "$output" 'Error: destination must be a directory when copying from stdin'
|
is "$output" 'Error: destination must be a directory when copying from stdin'
|
||||||
|
|
||||||
run_podman rm -f cpcontainer
|
run_podman rm -f cpcontainer
|
||||||
|
Reference in New Issue
Block a user