Copyright (C) 1999-2000 Steinar H. Gunderson
This program is is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License, version 2 if the
+ it under the terms of the GNU General Public License, version 2 of the
License as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
}
/* if no argument, choose all files */
- if (fptr == NULL || fptr[0] == 0) fptr = "*";
+ if (fptr == NULL || fptr[0] == 0) {
+ fptr = "*";
+ } else {
+ /* we need to check if the last part is a directory (no -d switch) */
+ struct stat buf;
+ if (stat(fptr, &buf) == 0 && S_ISDIR(buf.st_mode)) {
+ TRAP_ERROR(chdir(fptr) == -1, 550, return -1);
+ fptr = "*";
+ }
+ }
*ptr = fptr;
#if WANT_NONROOT