1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

chmod: Fix chmod -c --reference reporting when no change is made (#6016)

* Make fperm hold 6 digit octal permission. Set it to 4 digits when displaying

* Add test

* Make every permission 4 octal digits

* Change test name to be more suggestive

* chmod: merge two args in test

---------

Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
This commit is contained in:
Matei Mantu 2024-02-26 12:01:50 +02:00 committed by GitHub
parent a853a5b3ef
commit 095eced4be
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 1 deletions

View file

@ -101,7 +101,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let recursive = matches.get_flag(options::RECURSIVE); let recursive = matches.get_flag(options::RECURSIVE);
let fmode = match matches.get_one::<String>(options::REFERENCE) { let fmode = match matches.get_one::<String>(options::REFERENCE) {
Some(fref) => match fs::metadata(fref) { Some(fref) => match fs::metadata(fref) {
Ok(meta) => Some(meta.mode()), Ok(meta) => Some(meta.mode() & 0o7777),
Err(err) => { Err(err) => {
return Err(USimpleError::new( return Err(USimpleError::new(
1, 1,

View file

@ -645,6 +645,20 @@ fn test_quiet_n_verbose_used_multiple_times() {
.succeeds(); .succeeds();
} }
#[test]
fn test_changes_from_identical_reference() {
let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;
at.touch("file");
scene
.ucmd()
.arg("-c")
.arg("--reference=file")
.arg("file")
.succeeds()
.no_stdout();
}
#[test] #[test]
fn test_gnu_invalid_mode() { fn test_gnu_invalid_mode() {
let scene = TestScenario::new(util_name!()); let scene = TestScenario::new(util_name!());