1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-09-15 11:36:16 +00:00

Merge pull request #4888 from Ludmuterol/more-panic-4886

fix(#4886) more: panics if file is not readable
This commit is contained in:
Daniel Hofstetter 2023-05-24 17:42:27 +02:00 committed by GitHub
commit 81e3b04b11
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 1 deletions

View file

@ -32,3 +32,21 @@ fn test_more_dir_arg() {
.usage_error("'.' is a directory.");
}
}
#[test]
#[cfg(target_family = "unix")]
fn test_more_invalid_file_perms() {
use std::fs::{set_permissions, Permissions};
use std::os::unix::fs::PermissionsExt;
if std::io::stdout().is_terminal() {
let (at, mut ucmd) = at_and_ucmd!();
let permissions = Permissions::from_mode(0o244);
at.make_file("invalid-perms.txt");
set_permissions(at.plus("invalid-perms.txt"), permissions).unwrap();
ucmd.arg("invalid-perms.txt")
.fails()
.code_is(1)
.stderr_contains("permission denied");
}
}