File tree Expand file tree Collapse file tree 1 file changed +6
-12
lines changed Expand file tree Collapse file tree 1 file changed +6
-12
lines changed Original file line number Diff line number Diff line change @@ -228,18 +228,12 @@ pub fn write_history_to_file(history: &History, env: &Environment) {
228228 eprintln ! ( "sh: HISTFILE or HOME not set, history not saved" ) ;
229229 return ;
230230 } ;
231- match std:: fs:: File :: options ( ) . write ( true ) . open ( & path) {
232- Ok ( mut file) => {
233- for entry in & history. entries {
234- if let Err ( err) = writeln ! ( file, "{}" , entry. command) {
235- eprintln ! ( "sh: failed to write to history file at {} ({err})" , path) ;
236- return ;
237- }
238- }
239- }
240- Err ( err) => {
241- eprintln ! ( "sh: failed to open history file at {} ({err})" , path) ;
242- }
231+ let mut content = String :: new ( ) ;
232+ for entry in & history. entries {
233+ content. push_str ( & entry. command ) ;
234+ }
235+ if let Err ( err) = std:: fs:: write ( & path, content) {
236+ eprintln ! ( "sh: failed to open history file at {} ({err})" , path) ;
243237 }
244238}
245239
You can’t perform that action at this time.
0 commit comments