The branch, master has been updated
via 446eb11cdeba97a24996cee36ba331491aba6211 (commit)
from fa1375c09f13118c5be70aa6ba64284bdda1c03f (commit)
- Log -----------------------------------------------------------------
commit 446eb11cdeba97a24996cee36ba331491aba6211
Author: Nicholas Marriott <[email protected]>
Commit: Nicholas Marriott <[email protected]>
Make tilde expansion in command strings work even if it isn't terminated by
/.
---
cmd-string.c | 29 ++++++++++++++++++++++-------
1 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/cmd-string.c b/cmd-string.c
index 7e84eda..e793ea0 100644
--- a/cmd-string.c
+++ b/cmd-string.c
@@ -318,10 +318,13 @@ cmd_string_expand_tilde(const char *s, size_t *p)
{
struct passwd *pw;
struct environ_entry *envent;
- char *home, *path, *username;
+ char *home, *path, *user, *cp;
+ int last;
home = NULL;
- if (cmd_string_getc(s, p) == '/') {
+
+ last = cmd_string_getc(s, p);
+ if (last == EOF || last == '/' || last == ' '|| last == '\t') {
envent = environ_find(&global_environ, "HOME");
if (envent != NULL && *envent->value != '\0')
home = envent->value;
@@ -329,15 +332,27 @@ cmd_string_expand_tilde(const char *s, size_t *p)
home = pw->pw_dir;
} else {
cmd_string_ungetc(p);
- if ((username = cmd_string_string(s, p, '/', 0)) == NULL)
- return (NULL);
- if ((pw = getpwnam(username)) != NULL)
+
+ cp = user = xmalloc(strlen(s));
+ for (;;) {
+ last = cmd_string_getc(s, p);
+ if (last == EOF || last == '/' || last == ' '|| last ==
'\t')
+ break;
+ *cp++ = last;
+ }
+ *cp = '\0';
+
+ if ((pw = getpwnam(user)) != NULL)
home = pw->pw_dir;
- free(username);
+ free(user);
}
+
if (home == NULL)
return (NULL);
- xasprintf(&path, "%s/", home);
+ if (last != EOF)
+ xasprintf(&path, "%s%c", home, last);
+ else
+ xasprintf(&path, "%s", home);
return (path);
}
-----------------------------------------------------------------------
Summary of changes:
cmd-string.c | 29 ++++++++++++++++++++++-------
1 files changed, 22 insertions(+), 7 deletions(-)
hooks/post-receive
--
tmux
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
_______________________________________________
tmux-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tmux-cvs