-
Notifications
You must be signed in to change notification settings - Fork 142
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
Make it *very* obvious that sd will modify in-place #64
Comments
While I don't have a strong opinion on weather to modify in-place or not by default, I agree that the command-line help is misleading. |
Anyway, the help message should be updated, it's very misleading. |
I can agree. Perhaps a simple note here: ARGS:
<find>
The regexp or string (if -s) to search for
<replace-with>
What to replace each match with. Unless in string mode, you may use captured values like $1, $2, etc
<files>...
The path to file(s). This is optional - sd can also read from STDIN.
+ NOTE: sd modifies files in-place. See documentation for examples. Currently, from the
From reading the online docs, I felt immediately aware of the modify-in-place behavior. The docs also pointed out a very simple way to add backup functionality with a couple lines of shell. |
@jchook that looks good! Wanna submit a quick PR? |
Thanks @jchook ! |
First of all, thanks for the great tool! This is slowly becoming my default go-to instead of
sed
.I used
sd
today for the first time in a while, so I ransd --help
to refresh on the (admittedly intuitive) syntax.There was one line in the help dialog of note:
If I'm not mistaken, this line is out of date. By default,
sd
does modify files in-place.I would personally vote for this tool to not modify in-place to more closely match the behavior of
sed
,awk
, and other similar tools. I would argue that the most common use case for a tool like this is to run a few test cases through to ensure that you're doing what you think you're doing, iterate a few times, and then modify the file in place.However, I respect that you decided to move to the default of modifying in-place. I would ask, however, that we change the help text to make it very obvious that, by default, this tool modifies files in place. It can be very surprising to someone coming from
sed
,awk
, or a ton of other tools. I was lucky that I had recently committed my file togit
, otherwise I could have lost a lot of changes--my replacement did not behave the way I thought it would!I'm willing to submit a pull request if you'd be willing to merge such a change :)
Thanks again for the great tool!
The text was updated successfully, but these errors were encountered: