Subject: bin/2567: Restore could really use lcd/lpwd functions as ftp has...
To: None <gnats-bugs@NetBSD.ORG>
From: Grey Wolf <greywolf@starwolf.com>
List: netbsd-bugs
Date: 06/24/1996 15:34:12
>Number:         2567
>Category:       bin
>Synopsis:       Restore could really use lcd/lpwd functions as ftp has...
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Mon Jun 24 19:05:02 1996
>Last-Modified:
>Originator:     Grey Wolf
>Organization:
Star Wolf Innovations
>Release:        1.2_ALPHA
>Environment:
	userland + libs: 5/24 + partial rebuild.
	kernel: 6/4 source
System: NetBSD starjumper 1.2_ALPHA NetBSD 1.2_ALPHA (STARJUMPER) #16: Mon Jun 24 09:49:22 PDT 1996 greywolf@starjumper:/usr/src/sys/arch/sparc/compile/STARJUMPER sparc


>Description:
	It would be nice if, when one started a restore in the wrong directory,
	one did not have to kill restore, reposition the tape, and restart
	the restore.  I have created code for functions "lcd" and "lpwd"
	which change and reflect the process' idea of the current working
	UNIX directory.  See patch at the end of this report.
>How-To-Repeat:
	N/A.
>Fix:
*** interactive.c	Mon Jun 24 15:31:11 1996
--- interactive.c.orig	Mon Jun 24 10:56:37 1996
***************
*** 190,202 ****
  		if (strncmp(cmd, "help", strlen(cmd)) != 0)
  			goto bad;
  	case '?':
! 		fprintf(stderr, "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
  			"Available commands are:\n",
  			"\tls [arg] - list directory\n",
  			"\tcd arg - change directory\n",
- 			"\tlcd arg - change external directory\n",
  			"\tpwd - print current directory\n",
- 			"\tlpwd - print current external directory\n",
  			"\tadd [arg] - add `arg' to list of",
  			" files to be extracted\n",
  			"\tdelete [arg] - delete `arg' from",
--- 190,200 ----
  		if (strncmp(cmd, "help", strlen(cmd)) != 0)
  			goto bad;
  	case '?':
! 		fprintf(stderr, "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
  			"Available commands are:\n",
  			"\tls [arg] - list directory\n",
  			"\tcd arg - change directory\n",
  			"\tpwd - print current directory\n",
  			"\tadd [arg] - add `arg' to list of",
  			" files to be extracted\n",
  			"\tdelete [arg] - delete `arg' from",
***************
*** 215,236 ****
  	 * List a directory.
  	 */
  	case 'l':
! 		if (strncmp(cmd, "ls", strlen(cmd)) == 0)
! 		    printlist(name, curdir);
! 		else if (strncmp(cmd, "lcd", strlen(cmd)) == 0) {
! 		    char *wd;
! 		    if (chdir(name) < 0)
! 			perror(name);
! 		    wd = (char *) getcwd((char *)0, MAXPATHLEN);
! 		    fprintf(stderr, "Current working directory now %s\n", wd);
! 		    free (wd);
! 		}
! 		else if (strncmp(cmd, "lpwd", strlen(cmd)) == 0) {
! 		    char *wd = (char *)getcwd((char *)0, MAXPATHLEN);
! 		    fprintf(stderr, "%s\n", wd);
! 		    free(wd);
! 		}
! 		else goto bad;
  		break;
  	/*
  	 * Print current directory.
--- 213,221 ----
  	 * List a directory.
  	 */
  	case 'l':
! 		if (strncmp(cmd, "ls", strlen(cmd)) != 0)
! 			goto bad;
! 		printlist(name, curdir);
  		break;
  	/*
  	 * Print current directory.
***************
*** 377,383 ****
  	/*
  	 * If it is an absolute pathname, canonicalize it and return it.
  	 */
-     if (strncmp(cmd, "lcd", strlen(cmd))) {
  	if (rawname[0] == '/') {
  		canon(rawname, name);
  	} else {
--- 362,367 ----
***************
*** 390,398 ****
  		(void) strcat(output, rawname);
  		canon(output, name);
  	}
-     }
-     else
- 	(void) strcpy(name, rawname);
  	if (glob(name, GLOB_ALTDIRFUNC, NULL, &ap->glob) < 0)
  		fprintf(stderr, "%s: out of memory\n", ap->cmd);
  	if (ap->glob.gl_pathc == 0)
--- 374,379 ----
>Audit-Trail:
>Unformatted: