-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix #4767: chown -v 0 nf
isn't showing a message
#4768
Changes from 1 commit
03936f7
c13fae6
f2d8b0c
d22b723
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -730,15 +730,16 @@ fn test_chown_file_notexisting() { | |
let user_name = String::from(result.stdout_str().trim()); | ||
assert!(!user_name.is_empty()); | ||
|
||
let _result = scene | ||
let result = scene | ||
cakebaker marked this conversation as resolved.
Show resolved
Hide resolved
|
||
.ucmd() | ||
.arg(user_name) | ||
.arg(&user_name) | ||
.arg("--verbose") | ||
.arg("not_existing") | ||
.fails(); | ||
|
||
// TODO: uncomment once "failed to change ownership of '{}' to {}" added to stdout | ||
// result.stderr_contains("retained as"); | ||
result.stdout_contains(format!( | ||
"failed to change ownership of 'not_existing' to {user_name}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting that this message is different from the one that was commented out. Was that just a mistake? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could also add this assertion to the rest of the expression: scene
.ucmd()
...
.fails()
.stdout_contains(...); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The actual test tests a non existing file with verbose flag:
The string "retained as" is printed by the command:
These two cases came from the GNU test suite: tests/chown/basic.sh |
||
)); | ||
// TODO: uncomment once message changed from "cannot dereference" to "cannot access" | ||
// result.stderr_contains("cannot access 'not_existing': No such file or directory"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it makes sense to make a struct for the
(Option<u32>, Option<u32>, String, IfFrom)
? That would make it a bit easier to read (and make the types shorter).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also the
String
might need to be anOsString
if it can contain invalid utf-8.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
raw_owner: String
is constructed by either:matches.get_one::<String>( ... )
orentries::uid2usr(uid).unwrap_or_else(|_| uid.to_string())
I don't know if these two functions are robust enough to invalid utf-8.
If not, it might imply to refactor at least
uucore/*/perms.rs
,uu/*/chown.rs
,uu/*/chgrp.rs
. Then it should be useful to open a dedicated issue for it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I refactored
(Option<u32>, Option<u32>, String, IfFrom)
to a structGidUidOwnerFilter
.