[3160] in Athena Bugs

home help back first fref pref prev next nref lref last post

lsdel error message

daemon@ATHENA.MIT.EDU (Jonathan I. Kamens)
Mon Sep 11 04:33:55 1989

Date: Mon, 11 Sep 89 04:33:33 -0400
From: Jonathan I. Kamens <jik@ATHENA.MIT.EDU>
To: jfc@ATHENA.MIT.EDU
Cc: bugs@ATHENA.MIT.EDU
In-Reply-To: bugs[3159]
   Date: Mon, 11 Sep 89 02:21:58 EDT
   From: John Carr <jfc@ATHENA.MIT.EDU>


	   % lsdel
	   lsdel: .: no match
	   %

   I wonder what this means.  Perhaps perror() or com_err() would be in order,
   or a longer message ("no deleted files").

This is lossage, no doubt because I freed a char * and then later
tried to use it.  Lose, lose.

What *should* happen is that when there are no deleted files to list,
lsdel should return nothing, as does ls(1).  The patch to fix things
is below.

  jik

		      *************************

*** /tmp/,RCSt1010516	Mon Sep 11 04:30:35 1989
--- lsdel.c	Mon Sep 11 04:27:40 1989
***************
*** 115,141 ****
  	  }
  	  else {
  	       start_dir = "";
! 	       if ((*args[num - 1] == '.') && (! *(args[num - 1] + 1)))
! 		    file_re = parse_pattern("*");
! 	       else
! 		    file_re = parse_pattern(args[num - 1]);
  	  }
  	  if (! file_re)
  	       return(ERROR_MASK);
  
  	  found_files = get_the_files(start_dir, file_re, &num_found);
- 	  free(file_re);
  	  total += num_found;
  	  if (num_found)
  	       num_found = process_files(found_files, num_found);
  	  else {
  	       /* What we do at this point depends on exactly what the
! 	        * file_re is.  There are three possible conditions:
! 		* 1. It's an existing directory.  Print nothing.
! 		* 2. It doesn't exist in deleted form, and there are
! 		*    no wildcards in it.  Then we print "not found."
! 		* 3. It does't exist, but there are wildcards in it.
! 		*    Then we print "no match."
  		* None of these are considered error conditions, so we
  		* don't set the error flag.
  		*/
--- 115,139 ----
  	  }
  	  else {
  	       start_dir = "";
! 	       file_re = parse_pattern(args[num - 1]);
  	  }
  	  if (! file_re)
  	       return(ERROR_MASK);
  
  	  found_files = get_the_files(start_dir, file_re, &num_found);
  	  total += num_found;
  	  if (num_found)
  	       num_found = process_files(found_files, num_found);
  	  else {
  	       /* What we do at this point depends on exactly what the
! 	        * file_re is.  There are several possible conditions:
! 		* 1. file_re has no wildcards in it, which means that
! 		*    if we couldn't find it, that means it doesn't
! 		*    exist.  Print a not found error.
! 		* 2. file_re is an existing directory, with no deleted
! 		*    files in it.  Print nothing.
! 		* 3. file_re doesn't exist, and there are wildcards in
! 		*    it.  Print "no match".
  		* None of these are considered error conditions, so we
  		* don't set the error flag.
  		*/
***************
*** 150,155 ****
--- 148,154 ----
  			    whoami, args[num-1]);
  	       }
  	  }
+ 	  free(file_re);
       }
       if (total) {
  	  list_files();


home help back first fref pref prev next nref lref last post