rem: if ((errno != EISDIR && errno != EPERM) || ! x->recursive)
add: if (! x->recursive || errno == ENOENT || errno == ENOTDIR || errno == ELOOP || errno == ENAMETOOLONG)
context: remove_entry (Dirstack_state const *ds, char const *filename,	      struct rm_options const *x, struct dirent const *dp){  Ternary is_dir;  Ternary is_empty_directory;  enum RM_status s = prompt (ds, filename, x, PA_DESCEND_INTO_DIR,			     &is_dir, &is_empty_directory);  if (s != RM_OK)    return s;  /* Why bother with the following #if/#else block?  Because on systems with     an unlink function that *can* unlink directories, we must determine the     type of each entry before removing it.  Otherwise, we'd risk unlinking an     entire directory tree simply by unlinking a single directory;  then all     the storage associated with that hierarchy would not be freed until the     next reboot.  Not nice.  To avoid that, on such slightly losing systems, we     need to call lstat to determine the type of each entry, and that represents     extra overhead that -- it turns out -- we can avoid on GNU-libc-based     systems, since there, unlink will never remove a directory.  */#if ROOT_CAN_UNLINK_DIRS  /* If we don't already know whether FILENAME is a directory, find out now.     Then, if it's a non-directory, we can use unlink on it.  */  if (is_dir == T_UNKNOWN)    {# if HAVE_STRUCT_DIRENT_D_TYPE      if (dp && dp->d_type != DT_UNKNOWN)	is_dir = DT_IS_DIR (dp) ? T_YES : T_NO;      else# endif	{	  struct stat sbuf;	  if (lstat (filename, &sbuf))	    {	      if (errno == ENOENT && x->ignore_missing_files)		return RM_OK;	      error (0, errno,		     _("cannot lstat %s"), quote (full_filename (filename)));	      return RM_ERROR;	    }	  is_dir = S_ISDIR (sbuf.st_mode) ? T_YES : T_NO;	}    }  if (is_dir == T_NO)    {      /* At this point, barring race conditions, FILENAME is known	 to be a non-directory, so it's ok to try to unlink it.  */      DO_UNLINK (filename, x);      /* unlink failed with some other error code.  report it.  */      error (0, errno, _("cannot remove %s"),	     quote (full_filename (filename)));      return RM_ERROR;    }  if (! x->recursive)    {      error (0, EISDIR, _("cannot remove directory %s"),	     quote (full_filename (filename)));      return RM_ERROR;    }  if (is_empty_directory == T_YES)    {      DO_RMDIR (filename, x);      /* Don't diagnose any failure here.	 It'll be detected when the caller tries another way.  */    }#else /* ! ROOT_CAN_UNLINK_DIRS */  if (is_dir == T_YES && ! x->recursive)    {      error (0, EISDIR, _("cannot remove directory %s"),	     quote (full_filename (filename)));      return RM_ERROR;    }  /* is_empty_directory is set iff it's ok to use rmdir.     Note that it's set only in interactive mode -- in which case it's     an optimization that arranges so that the user is asked just     once whether to remove the directory.  */  if (is_empty_directory == T_YES)    DO_RMDIR (filename, x);  /* If we happen to know that FILENAME is a directory, return now     and let the caller remove it -- this saves the overhead of a failed     unlink call.  If FILENAME is a command-line argument, then dp is NULL,     so we'll first try to unlink it.  Using unlink here is ok, because it     cannot remove a directory.  */#if HAVE_STRUCT_DIRENT_D_TYPE  if ((dp && DT_IS_DIR (dp)) || is_dir == T_YES)    return RM_NONEMPTY_DIR;#endif  DO_UNLINK (filename, x);  /* Accept either EISDIR or EPERM as an indication that FILENAME may be     a directory.  POSIX says that unlink must set errno to EPERM when it     fails to remove a directory, while Linux-2.4.18 sets it to EISDIR.  */  if ((errno != EISDIR && errno != EPERM) || ! x->recursive)    {      /* some other error code.  Report it and fail.	 Likewise, if we're trying to remove a directory without	 the --recursive option.  */      error (0, errno, _("cannot remove %s"),	     quote (full_filename (filename)));      return RM_ERROR;    }#endif  return RM_NONEMPTY_DIR;}