hello i made a typo while trying to open a txt file in vi i gave vi a directory, vi to my amazement opened the directory on the console filled with garbage characters, instead of saying cant open a directory. anyone had this?
nedry
od /usr/bin
. Normally you would only read it using readdir(3) and similar.Warning: test is not a regular file; test: unmodified: line 1
P.S. I hope nobody is crazy in FreeBSD camp to link vi to vim binaries like Linux does.
hello i made a typo while trying to open a txt file in vi i gave vi a directory, vi to my amazement opened the directory on the console filled with garbage characters, instead of saying cant open a directory. anyone had this?
nedry
I'm sure it wouldn't have been a big leap to implement them that way.
Like others already noted the directory is just another file. This methodology is called "everything is a file" -methodology. In this case a directory is presented as a file with special semantics when handled with proper tools like ls(1) but will show the raw binary data when handled with tools that don't understand the underlying structure such as cat(1). UNIX and UNIX-like OSes tend to do this alot, just look at the how the /dev/* devices work. The only exceptions have been the network interfaces that for some arcane reasons never were presented as /dev devices although I'm sure it wouldn't have been a big leap to implement them that way.
# mount -t tmpfs none /mnt
# mkdir /mnt/blablabla
# cat /mnt/blablabla
cat: /mnt/blablabla: Is a directory