-
Notifications
You must be signed in to change notification settings - Fork 122
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
Command-line tool clears the file if the output file path is identical to the input file path #78
Comments
Thanks, I'd say it sounds important to catch that case so we aren't accidentally clearing files. (Although, my data cleaning pipeline usually involves writing to a different file, not the same file -- what if ftfy changes, or you want to run it with different options?) |
I also just ran into this error. GNU sed has a similar problem and solves it by adding the "-i" flag, which does an in-place replacement. So an example invocation would be That would also make it harder to do by accident (maybe error out if output and input are the same, and buffer the output in a temporary file for the -i solution). A workaround I've used is sponge(1) from moreutils and use output redirection instead of ftfy's -o option:
|
Usage example:
ftfy -e windows-1251 -o weirdfile.txt weirdfile.txt
Result: An empty file.
The text was updated successfully, but these errors were encountered: