-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
touch no-file/
fails with a sub optimal error
#2639
Comments
The current uutils behaviour is:
|
not great either :) |
May I give this a shot? |
Yeah, go ahead! |
I checked out main and ran
It seems this issue has been already addressed in #2408. The code that handled this was later removed in 0cfaaec#diff-9565d8fad7b29837b3b468a61a809dc187fb351a72421ffe4b7c4879a8445b27R85 but the test from the PR is still in place and is passing.
How (platform, version of uutils) are you getting this behaviour? I couldn't reproduce it (macos, built from main). |
Maybe it depends on whether or not |
@tertsdiepraam I did try these scenarios and they all seem to behave as expected: $ touch non-existent
# no output, creates a file named "non-existent"
$ touch non-existent/
touch: cannot touch 'non-existent/': No such file or directory
$ touch existing-dir
# no output, touches the dir
$ touch existing-dir/
# no output, touches the dir these behaviors are consistent across my default touch implementation (BSD), GNU's and uutils'. Except the slight wording differences: BSD's leaves out the
The case when Anyway, the uutils' implementation seems to behave just this issue proposes. Am I missing something? |
Very curious, I'm still getting the same result, but maybe it's me who's missing something :) I'm on Linux and on the main branch.
Oh yeah, that's true. Thanks for pointing that out! |
Curious indeed! Seems like maybe the platform is the culprit here. Gimme some more time to try on linux as well. And also to find out where exactly these messages originate. |
The issue appears to originate in this block. The On Linux, printing the error gives The last part of the error message on each platform appears to be just the |
Thanks for investigating this!
Yes that is correct |
It seems to me that there might need to be some custom error message rules around this, since modifying the implementation of I'm thinking something like take the error from line 119 and then write a function that interprets it based on the OS and outputs the appropriate error message. Would that be an acceptable solution? (Also, I'm not tied to writing this---if @goodhoko still wants to work on this, I would be happy to let them). |
I checked GNU to see what they do and where the discrepancy comes from. They do the following:
Hence, if a non-existent directory is given, the creation fails (with I agree that we shouldn't change @sylvestre, what is your opinion here? |
Two quick things to note:
I don't know to what extend cross-platform consistency in error messaging is a goal here, but to get MacOS to behave like the other two platforms would require an additional check upon first getting this error. |
Sorry for ghosting this. 🙈 Life dragged me somewhere else. Feel free to take over this. |
Hello, I would like to work on this. @chipbuster Could you tell me what error message has to be shown for an OS? I was thinking of I'm not sure for Windows as their default error message is confusing. |
Unfortunately, you're asking the wrong person. My only contribution to this project has been identifying the source of the error strings--my opinion on what the right message should be matters less than yours, if you end up implementing this, and much less than anyone with some actual involvement with this project |
Shouldn't this issue be closed due to this PR? |
It is still there (linux, debian): $ coreutils touch no-file/
touch: cannot touch 'no-file/': Is a directory
$ coreutils --help | grep multi
coreutils 0.0.25 (multi-call binary) |
GNU:
We should probably mix the two and have
The code is in:
coreutils/src/uu/touch/src/touch.rs
Line 88 in 1bb23cd
@miDeb Any idea how to implement that? thanks :)
The text was updated successfully, but these errors were encountered: