From 39ef26690c43c83614ea4689af1c83a8955d33f2 Mon Sep 17 00:00:00 2001 From: Philippe Pepiot Date: Thu, 15 Oct 2009 20:49:03 +0200 Subject: [PATCH] Launcher: Replace ~/ by $HOME/ --- src/launcher.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/launcher.c b/src/launcher.c index 074cc6a..dcb6c2e 100644 --- a/src/launcher.c +++ b/src/launcher.c @@ -275,7 +275,17 @@ complete_on_files(char *start, size_t hits) path = _strdup("."); else { - dirname = _strdup(p); + /* remplace ~ by $HOME in dirname */ + if (!strncmp(p, "~/", 2) && getenv("HOME")) + asprintf(&dirname, "%s%s", getenv("HOME"), p+1); + else + dirname = _strdup(p); + + /* Set p to filename to be complete + * and path the directory containing the file + * /foooooo/baaaaaar/somethinglikethis + * <---- path - ---><------- p ------> + */ p = strrchr(dirname, '/'); if (p != dirname) {