/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1982-2012 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* David Korn <dgk@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* cd [-LP] [dirname]
* cd [-LP] [old] [new]
* pwd [-LP]
*
* David Korn
* AT&T Labs
* research!dgk
*
*/
#include "defs.h"
#include <stak.h>
#include <error.h>
#include "variables.h"
#include "path.h"
#include "name.h"
#include "builtins.h"
#include <ls.h>
/*
* Invalidate path name bindings to relative paths
*/
{
}
{
register char *dir;
register const char *dp;
int saverrno=0;
char *oldpwd;
if(sh_isoption(SH_RESTRICTED))
{
case 'L':
flag = 0;
break;
case 'P':
flag = 1;
break;
case ':':
break;
case '?':
break;
}
if(argc==2)
else if(!dir)
#if _WINIX
#else
if(*dir != '/')
#endif /* _WINIX */
{
{
{
}
}
if(!oldpwd)
}
if(*dir=='.')
{
/* test for pathname . ./ .. or ../ */
int n=0;
char *sp;
{
n++;
break;
if(*dp==0)
break;
}
if(n)
{
cdpath = 0;
while(n--)
{
break;
}
}
}
rval = -1;
do
{
#if _WINIX
{
}
#endif /* _WINIX */
{
/* don't add '/' of oldpwd is / itself */
stakputc('/');
stakputc(0);
}
if(!flag)
{
register char *cp;
#if SHOPT_FS_3D
continue;
/* eliminate trailing '/' */
*cp = 0;
#else
continue;
#endif /* SHOPT_FS_3D */
}
goto success;
}
while(cdpath);
/* use absolute chdir() if relative chdir() fails */
if(rval<0)
{
if(saverrno)
}
if(flag)
{
{
}
}
if(*dir != '/')
return(0);
/* delete trailing '/' */
if(oldpwd)
return(0);
}
{
register int n, flag = 0;
register char *cp;
{
case 'L':
flag = 0;
break;
case 'P':
flag = 1;
break;
case ':':
break;
case '?':
break;
}
if(error_info.errors)
if(flag)
{
#if SHOPT_FS_3D
{
}
else
#endif /* SHOPT_FS_3D */
}
return(0);
}