diff options
author | Daniel Carl <danielcarl@gmx.de> | 2014-06-05 23:46:42 +0200 |
---|---|---|
committer | Daniel Carl <danielcarl@gmx.de> | 2014-06-05 23:46:42 +0200 |
commit | 38b7d109ea5e38a25c51789315ce7174d19a6c3f (patch) | |
tree | 53e51b235e61abd2023662e622a9133933d0d74a /src/util.c | |
parent | be73f0a23d2a7346f9282351783eba4a6e05dc50 (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.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -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 == '$') |