summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authorDaniel Carl <danielcarl@gmx.de>2014-06-05 23:46:42 +0200
committerDaniel Carl <danielcarl@gmx.de>2014-06-05 23:46:42 +0200
commit38b7d109ea5e38a25c51789315ce7174d19a6c3f (patch)
tree53e51b235e61abd2023662e622a9133933d0d74a /src/util.c
parentbe73f0a23d2a7346f9282351783eba4a6e05dc50 (diff)
Fixed trailing / in ~/ expansion.
If ~/ was expanded the path had a trailing / but according to the shell this should end up in directory without a slash.
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/util.c b/src/util.c
index 0dcd0c3..94edd7c 100644
--- a/src/util.c
+++ b/src/util.c
@@ -398,6 +398,11 @@ gboolean util_parse_expansion(const char **input, GString *str, int flags,
if (**input == '/') {
g_string_append(str, util_get_home_dir());
expanded = true;
+ /* if there is no char or space after ~/ skip the / to get
+ * /home/user instead of /home/user/ */
+ if (!*(*input + 1) || VB_IS_SPACE(*(*input + 1))) {
+ (*input)++;
+ }
} else {
/* look ahead to / space or end of string to get a possible
* username for ~user pattern */
@@ -468,9 +473,10 @@ gboolean util_parse_expansion(const char **input, GString *str, int flags,
if (**input == quote) {
/* move pointer to the next char */
(*input)++;
- if (!*input) {
+ if (!**input) {
/* if input ends here - use only the quote char */
g_string_append_c(str, quote);
+ (*input)--;
} else if (strchr(quoteable, **input)
|| (flags & UTIL_EXP_TILDE && **input == '~')
|| (flags & UTIL_EXP_DOLLAR && **input == '$')