Skip to content

Commit 3e1e617

Browse files
committed
chmod: Use full "permission denied" error message
Part of the error message was left out due to a misreading of tests/chmod/no-x's output. It filters out this part for the sake of normalization between different tools.
1 parent e402404 commit 3e1e617

File tree

4 files changed

+5
-7
lines changed

4 files changed

+5
-7
lines changed

src/uu/chmod/locales/en-US.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ chmod-error-dangling-symlink = cannot operate on dangling symlink {$file}
99
chmod-error-no-such-file = cannot access {$file}: No such file or directory
1010
chmod-error-preserve-root = it is dangerous to operate recursively on {$file}
1111
chmod: use --no-preserve-root to override this failsafe
12-
chmod-error-permission-denied = {$file}: Permission denied
12+
chmod-error-permission-denied = cannot access {$file}: Permission denied
1313
chmod-error-new-permissions = {$file}: new permissions are {$actual}, not {$expected}
1414
chmod-error-missing-operand = missing operand
1515

src/uu/chmod/locales/fr-FR.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ chmod-error-dangling-symlink = impossible d'opérer sur le lien symbolique pendo
2121
chmod-error-no-such-file = impossible d'accéder à {$file} : Aucun fichier ou répertoire de ce type
2222
chmod-error-preserve-root = il est dangereux d'opérer récursivement sur {$file}
2323
chmod: utiliser --no-preserve-root pour outrepasser cette protection
24-
chmod-error-permission-denied = {$file} : Permission refusée
24+
chmod-error-permission-denied = impossible d'accéder à {$file} : Permission refusée
2525
chmod-error-new-permissions = {$file} : les nouvelles permissions sont {$actual}, pas {$expected}
2626
chmod-error-missing-operand = opérande manquant
2727

src/uu/chmod/src/chmod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ enum ChmodError {
3434
NoSuchFile(PathBuf),
3535
#[error("{}", translate!("chmod-error-preserve-root", "file" => _0.quote()))]
3636
PreserveRoot(PathBuf),
37-
#[error("{}", translate!("chmod-error-permission-denied", "file" => _0.maybe_quote()))]
37+
#[error("{}", translate!("chmod-error-permission-denied", "file" => _0.quote()))]
3838
PermissionDenied(PathBuf),
3939
#[error("{}", translate!("chmod-error-new-permissions", "file" => _0.maybe_quote(), "actual" => _1.clone(), "expected" => _2.clone()))]
4040
NewPermissions(PathBuf, String, String),
@@ -614,8 +614,6 @@ impl Chmoder {
614614
}
615615
Ok(()) // Skip dangling symlinks
616616
} else if err.kind() == std::io::ErrorKind::PermissionDenied {
617-
// These two filenames would normally be conditionally
618-
// quoted, but GNU's tests expect them to always be quoted
619617
Err(ChmodError::PermissionDenied(file.into()).into())
620618
} else {
621619
Err(ChmodError::CannotStat(file.into()).into())

tests/by-util/test_chmod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ fn test_permission_denied() {
371371
.arg("o=r")
372372
.arg("d")
373373
.fails()
374-
.stderr_is("chmod: d/no-x/y: Permission denied\n");
374+
.stderr_is("chmod: cannot access 'd/no-x/y': Permission denied\n");
375375
}
376376

377377
#[test]
@@ -394,7 +394,7 @@ fn test_chmod_recursive() {
394394
#[cfg(not(target_os = "linux"))]
395395
let err_msg = "chmod: Permission denied\n";
396396
#[cfg(target_os = "linux")]
397-
let err_msg = "chmod: z: Permission denied\n";
397+
let err_msg = "chmod: cannot access 'z': Permission denied\n";
398398

399399
// only the permissions of folder `a` and `z` are changed
400400
// folder can't be read after read permission is removed

0 commit comments

Comments
 (0)