From: NeilBrown Date: Sun, 20 Mar 2011 05:29:26 +0000 (+1100) Subject: lafs: save history to ~/.lafs_history X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=2d9559ec6074eb4170a41e362dc2a37e5309820c;p=lafs-utils.git lafs: save history to ~/.lafs_history Signed-off-by: NeilBrown --- diff --git a/tools/lafs.c b/tools/lafs.c index 0a6dc2f..d461a64 100644 --- a/tools/lafs.c +++ b/tools/lafs.c @@ -376,12 +376,19 @@ static char **complete_in_context(const char *word, int start, int end); static void interact(void) { struct state st = {0}; + char *home, *hist; st.lafs = lafs_alloc(); st.verbose = 1; rl_attempted_completion_function = complete_in_context; rl_basic_word_break_characters = " \t\n="; rl_completer_quote_characters = "\"'"; rl_initialize(); + + home = getenv("HOME"); + if (!home) + home = "."; + asprintf(&hist, "%s/.lafs_history", home); + read_history(hist); while (!st.done) { char *line = readline("LaFS: "); @@ -397,6 +404,7 @@ static void interact(void) free(line); } + write_history(hist); } /* 'runfile' is the alternate interface when a regular file is