marked icon indicating copy to clipboard operation
marked copied to clipboard

Is it possible to add a noclobber option?

Open nonopolarity opened this issue 4 years ago • 8 comments

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

nonopolarity avatar Apr 13 '21 00:04 nonopolarity

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

UziTech avatar Apr 13 '21 00:04 UziTech

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

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

nonopolarity avatar Apr 13 '21 01:04 nonopolarity

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

UziTech avatar Apr 13 '21 01:04 UziTech

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

nonopolarity avatar Apr 13 '21 01:04 nonopolarity

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 avatar Apr 13 '21 02:04 UziTech

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.

UziTech avatar Apr 13 '21 02:04 UziTech

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.

nonopolarity avatar Apr 14 '21 03:04 nonopolarity

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

UziTech avatar Apr 14 '21 03:04 UziTech

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?

tristan-f-r avatar Jan 10 '23 13:01 tristan-f-r

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

UziTech avatar Jan 10 '23 23:01 UziTech