summaryrefslogtreecommitdiffstats
path: root/bin/sh/expand.c
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2014-10-05 21:51:36 +0000
committerjilles <jilles@FreeBSD.org>2014-10-05 21:51:36 +0000
commit8883e8ad3ea72532152caf26aaa12be04744a63f (patch)
treeb00ee3e4cda755dd02e5000755469b550cf3c8ca /bin/sh/expand.c
parenta25e91cfdb087b8b2986b66a6a47e8012daede14 (diff)
downloadFreeBSD-src-8883e8ad3ea72532152caf26aaa12be04744a63f.zip
FreeBSD-src-8883e8ad3ea72532152caf26aaa12be04744a63f.tar.gz
sh: Eliminate some gotos.
Diffstat (limited to 'bin/sh/expand.c')
-rw-r--r--bin/sh/expand.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/bin/sh/expand.c b/bin/sh/expand.c
index 15afc9c..b716f5c 100644
--- a/bin/sh/expand.c
+++ b/bin/sh/expand.c
@@ -328,24 +328,19 @@ exptilde(char *p, int flag)
done:
*p = '\0';
if (*(startp+1) == '\0') {
- if ((home = lookupvar("HOME")) == NULL)
- goto lose;
+ home = lookupvar("HOME");
} else {
- if ((pw = getpwnam(startp+1)) == NULL)
- goto lose;
- home = pw->pw_dir;
+ pw = getpwnam(startp+1);
+ home = pw != NULL ? pw->pw_dir : NULL;
}
- if (*home == '\0')
- goto lose;
*p = c;
+ if (home == NULL || *home == '\0')
+ return (startp);
if (quotes)
STPUTS_QUOTES(home, SQSYNTAX, expdest);
else
STPUTS(home, expdest);
return (p);
-lose:
- *p = c;
- return (startp);
}
OpenPOWER on IntegriCloud