less -f
Chuck Swiger
cswiger at mac.com
Wed Dec 29 17:08:19 PST 2004
Joshua Lokken wrote:
[ ... ]
> So, I did man less(1), and found this:
>
> -f or --force
> Forces non-regular files to be opened. (A non-regular file is a
> directory or a device special file.) Also suppresses the warn-
> ing message when a binary file is opened. By default, less will
> refuse to open non-regular files.
>
> However,:
[ ... ]
>less -f ~netmin/mydir
> /home/netmin/mydir is a directory
>
> Can someone explain this behavior to me? I admit that I may
> not understand the -f flag wholly, however, this seems in direct
> contradiction with the man page.
You're right, the manpage says and what the program actually does contradict
each other. Consider the following change to /usr/src/contrib/less:
--- filename.c~ Thu Jun 29 21:03:08 2000
+++ filename.c Wed Dec 29 20:04:06 2004
@@ -954,10 +954,14 @@
{
static char is_dir[] = " is a directory";
- m = (char *) ecalloc(strlen(filename) + sizeof(is_dir),
- sizeof(char));
- strcpy(m, filename);
- strcat(m, is_dir);
+ if (force_open) {
+ m = NULL;
+ } else {
+ m = (char *) ecalloc(strlen(filename) + sizeof(is_dir),
+ sizeof(char));
+ strcpy(m, filename);
+ strcat(m, is_dir);
+ }
} else
{
--
-Chuck
More information about the freebsd-questions
mailing list