summaryrefslogtreecommitdiff
path: root/bin/ksh/eval.c
diff options
context:
space:
mode:
authorcbiere <cbiere@NetBSD.org>2007-01-28 20:01:02 +0000
committercbiere <cbiere@NetBSD.org>2007-01-28 20:01:02 +0000
commitecc8aad21de61dc324eb275b58f5ea83872ff6db (patch)
treef36c957bd0386b6510343c69c806bffd8b76fe0a /bin/ksh/eval.c
parent4ce24268ac201aa791a29edc8e01bae8ce6f9114 (diff)
Committed patch from PR bin/34755: Append a slash when expanding ~user
to user's home directory.
Diffstat (limited to 'bin/ksh/eval.c')
-rw-r--r--bin/ksh/eval.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/bin/ksh/eval.c b/bin/ksh/eval.c
index 0866e24647f..96efa0e4484 100644
--- a/bin/ksh/eval.c
+++ b/bin/ksh/eval.c
@@ -1,4 +1,4 @@
-/* $NetBSD: eval.c,v 1.7 2006/05/13 21:48:00 christos Exp $ */
+/* $NetBSD: eval.c,v 1.8 2007/01/28 20:01:02 cbiere Exp $ */
/*
* Expansion - quoting, separation, substitution, globbing
@@ -6,7 +6,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: eval.c,v 1.7 2006/05/13 21:48:00 christos Exp $");
+__RCSID("$NetBSD: eval.c,v 1.8 2007/01/28 20:01:02 cbiere Exp $");
#endif
@@ -1302,11 +1302,19 @@ homedir(name)
return NULL;
#else /* OS2 */
struct passwd *pw;
+ size_t n;
pw = getpwnam(name);
if (pw == NULL)
return NULL;
- ap->val.s = str_save(pw->pw_dir, APERM);
+ n = strlen(pw->pw_dir);
+ if (n > 0 && '/' != pw->pw_dir[n - 1]) {
+ ap->val.s = str_nsave(pw->pw_dir, n + 1, APERM);
+ ap->val.s[n] = '/';
+ ap->val.s[n + 1] = '\0';
+ } else {
+ ap->val.s = str_save(pw->pw_dir, APERM);
+ }
ap->flag |= DEFINED|ISSET|ALLOC;
#endif /* OS2 */
}