Create history file if it does not exist

This commit is contained in:
Matthias Beyer 2016-09-30 16:00:58 +02:00
parent 734826a2cd
commit 846c2d0325
2 changed files with 7 additions and 0 deletions

View file

@ -28,6 +28,7 @@ generate_error_module!(
ConfigMissingError => "Configuration missing", ConfigMissingError => "Configuration missing",
ConfigTypeError => "Config Type Error", ConfigTypeError => "Config Type Error",
NoConfigError => "No configuration", NoConfigError => "No configuration",
ReadlineHistoryFileCreationError => "Could not create history file for readline",
ReadlineError => "Readline error" ReadlineError => "Readline error"
); );
); );

View file

@ -84,6 +84,12 @@ impl Readline {
.build(); .build();
let mut editor = Editor::new(config); let mut editor = Editor::new(config);
if !histfile.exists() {
let _ = try!(File::create(histfile.clone())
.map_err_into(IEK::ReadlineHistoryFileCreationError));
}
let _ = try!(editor.load_history(&histfile).map_err_into(ReadlineError)); let _ = try!(editor.load_history(&histfile).map_err_into(ReadlineError));
Ok(Readline { Ok(Readline {