Skip to content
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

Is it possible to add a noclobber option? #2012

Closed
nonopolarity opened this issue Apr 13, 2021 · 10 comments · Fixed by #3025
Closed

Is it possible to add a noclobber option? #2012

nonopolarity opened this issue Apr 13, 2021 · 10 comments · Fixed by #3025
Labels
category: cli good first issue Something easy to get started with proposal

Comments

@nonopolarity
Copy link

Describe the feature
so that any existing file is not overwritten

Why is this feature necessary?
prevent accidentally overwriting the file

Describe alternatives you've considered

@UziTech
Copy link
Member

UziTech commented Apr 13, 2021

Not sure what you mean. marked doesn't write to any files.

@nonopolarity
Copy link
Author

Not sure what you mean. marked doesn't write to any files.

when we do marked -i README.md -o README.html

@UziTech
Copy link
Member

UziTech commented Apr 13, 2021

You want an option to make sure the input file is not the same as the output file?

@nonopolarity
Copy link
Author

You want an option to make sure the input file is not the same as the output file?

note marked -i README.md -o README.html the md vs html

@UziTech
Copy link
Member

UziTech commented Apr 13, 2021

note marked -i README.md -o README.html the md vs html

So it shouldn't overwrite the input file. I'm not exactly sure what you are looking for.

@UziTech
Copy link
Member

UziTech commented Apr 13, 2021

If you don't want to overwrite the file can't you just make sure the files are different? I don't know how adding an option would help that.

@nonopolarity
Copy link
Author

for example, Bash has an option to set noclobber, and when we use any app, we save it as README.html, it'd say the file already exists, would you like to save anyway. So I think commands can make sense if it has a noclobber option, just so that there is no accidental overwrite.

@UziTech UziTech closed this as completed Apr 14, 2021
@UziTech UziTech reopened this Apr 14, 2021
@UziTech
Copy link
Member

UziTech commented Apr 14, 2021

I would be ok with that if you want to create a PR

@LeoDog896
Copy link
Contributor

I actually can't find an example of a CLI implementing noclobber -- can someone here send an example of a CLI either reading from the bash environment to detect if the noclobber option was set, or explicitly passing a flag?

@UziTech
Copy link
Member

UziTech commented Jan 10, 2023

cp has a --no-clobber option to prevent overriding files. https://man7.org/linux/man-pages/man1/cp.1.html

@UziTech UziTech added the good first issue Something easy to get started with label Sep 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: cli good first issue Something easy to get started with proposal
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants