Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES cd.c
#include <config.h>
#endif
#include "../bashtypes.h"
-#include "../posixdir.h"
-#include "../posixstat.h"
+#include "posixdir.h"
+#include "posixstat.h"
#ifndef _MINIX
#include <sys/param.h>
#endif
#include "../shell.h"
#include "../flags.h"
-#include "../maxpath.h"
+#include "maxpath.h"
#include "common.h"
#include "bashgetopt.h"
to be followed.
$END
-/* Take PATH, an element from $CDPATH, and DIR, a directory name, and paste
- them together into PATH/DIR. Tilde expansion is performed on PATH if
- DOTILDE is non-zero. If PATH is the empty string, it is converted to
- `./', since a null element in $CDPATH means the current directory. */
-static char *
-mkpath (path, dir, dotilde)
- char *path, *dir;
- int dotilde;
-{
- int dirlen, pathlen;
- char *ret, *xpath;
-
- if (*path == '\0')
- {
- xpath = xmalloc (2);
- xpath[0] = '.';
- xpath[1] = '\0';
- pathlen = 1;
- }
- else
- {
- xpath = (dotilde && *path == '~') ? bash_tilde_expand (path) : path;
- pathlen = strlen (xpath);
- }
-
- dirlen = strlen (dir);
- ret = xmalloc (2 + dirlen + pathlen);
- strcpy (ret, xpath);
- if (xpath[pathlen - 1] != '/')
- {
- ret[pathlen++] = '/';
- ret[pathlen] = '\0';
- }
- strcpy (ret + pathlen, dir);
- if (xpath != path)
- free (xpath);
- return (ret);
-}
-
static int
bindpwd (no_symlinks)
int no_symlinks;
{
/* OPT is 1 if the path element is non-empty */
opt = path[0] != '\0';
- temp = mkpath (path, dirname, 1);
+ temp = sh_makepath (path, dirname, MP_DOTILDE);
free (path);
if (stat (temp, &sb) < 0 || S_ISDIR (sb.st_mode) == 0)