summaryrefslogtreecommitdiffstats
path: root/bin/sh
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>1994-12-26 13:02:05 +0000
committerbde <bde@FreeBSD.org>1994-12-26 13:02:05 +0000
commitd82158a7e001222b1a02dc1bb22a776d25040970 (patch)
tree699d67d689f14964f232abad4cdeca9fa67c77ee /bin/sh
parentc73adf1de827e599d3b3e4d1c5938fcc32b30209 (diff)
downloadFreeBSD-src-d82158a7e001222b1a02dc1bb22a776d25040970.zip
FreeBSD-src-d82158a7e001222b1a02dc1bb22a776d25040970.tar.gz
Obtained from: partly from 1.1.5
Convert "" to "." for "cd" and "cd ''". chdir("") is required to fail on POSIX systems.
Diffstat (limited to 'bin/sh')
-rw-r--r--bin/sh/cd.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/bin/sh/cd.c b/bin/sh/cd.c
index 29bc1fd..ac44069 100644
--- a/bin/sh/cd.c
+++ b/bin/sh/cd.c
@@ -33,7 +33,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: cd.c,v 1.2 1994/09/24 02:57:24 davidg Exp $
+ * $Id: cd.c,v 1.3 1994/11/06 01:29:26 jkh Exp $
*/
#ifndef lint
@@ -88,6 +88,8 @@ cdcmd(argc, argv) char **argv; {
nextopt(nullstr);
if ((dest = *argptr) == NULL && (dest = bltinlookup("HOME", 1)) == NULL)
error("HOME not set");
+ if (*dest == '\0')
+ dest = ".";
if (dest[0] == '-' && dest[1] == '\0') {
dest = prevdir ? prevdir : curdir;
print = 1;
@@ -220,7 +222,7 @@ top:
STPUTC('\0', p);
p = grabstackstr(p);
INTOFF;
- if (chdir(p) < 0) {
+ if (chdir(*p ? p : ".") < 0) {
INTON;
return -1;
}
OpenPOWER on IntegriCloud