Bug 231190

Summary: created a file with touch that can not be removed
Product: Base System Reporter: todd <tcarpenter604>
Component: miscAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed Not A Bug    
Severity: Affects Only Me    
Priority: ---    
Version: 11.2-STABLE   
Hardware: amd64   
OS: Any   

Description todd 2018-09-06 04:26:59 UTC
Hi Guys,

Unfortunately this bug was caused by a type-o when using the "touch" command.  This resulted in a file I can not modify, delete, move, copy or otherwise destroy.  I can chmod/own it..

It seems like every command that accesses the file thinks its a -t argument.

I cant even attach the file.  Its a normal 0 byte file that was created with touch

here are some examples:  (the -type file is the first one.. I just included it for context as shows up before .hidden files yet is fully visible)

-rw-r--r--  1 todd  todd           0 Aug 21 00:46 -type
drwxr-xr-x  3 todd  todd          17 Sep  5 21:01 .
drwxr-xr-x  3 root  wheel          3 Aug 19 16:18 ..
-rw-r--r--  1 todd  todd        1055 Aug 19 16:18 .cshrc
-rw-r--r--  1 todd  todd         392 Aug 19 16:18 .login
-rw-r--r--  1 todd  todd         163 Aug 19 16:18 .login_conf
-rw-------  1 todd  todd         379 Aug 19 16:18 .mail_aliases
-rw-r--r--  1 todd  todd         336 Aug 19 16:18 .mailrc
-rw-r--r--  1 todd  todd         952 Aug 19 16:18 .profile
-rw-------  1 todd  todd         281 Aug 19 16:18 .rhosts
-rw-r--r--  1 todd  todd         851 Aug 19 16:18 .shrc
drwx------  2 todd  todd           3 Aug 28 03:49 .ssh

it shows up with a normal ls
root@abyss:/home/todd # ls
-type           .login_conf     .profile        .ssh            test.sh
.cshrc          .mail_aliases   .rhosts         install63.iso   type
.login          .mailrc         .shrc           zfs_health.sh

vi -type   (errors)

ype: tag not found; Error: tags: No such file or directory.
/tmp/vi.cYpFkc2AwI: new file: line 1
Press any key to continue:

if I cat it i get a switch error.

root@abyss:/home/todd # cat: illegal option -- y
cat:: Too many arguments.
root@abyss:/home/todd # usage: cat [-belnstuv] [file ...]
usage:: Too many arguments.

chown: no problem 

root@abyss:/home/todd # chown todd:todd -type
root@abyss:/home/todd #

root@abyss:/home/todd # chown root:wheel -type
root@abyss:/home/todd # ls -la
total 331069
-rw-r--r--  1 root  wheel          0 Aug 21 00:46 -type

rm .. or any other command like cp mv etc

root@abyss:/home/todd # rm -type
rm: illegal option -- t
usage: rm [-f | -i] [-dIPRrvWx] file ...
       unlink file

lol for the life of me I can't get rid of this file.  I cant even attach it or copy it .. etc.. but its just a touched 0 byte file..

Comment 1 Oleksandr Tymoshenko freebsd_committer freebsd_triage 2018-09-06 04:32:42 UTC
(In reply to todd from comment #0)

You can pass filename starting with - to a utility using "--" as marker for end of arguments:

rm -- -type
vi -- -type
Comment 2 Conrad Meyer freebsd_committer 2018-09-06 14:27:15 UTC
(Or use "./-type")
Comment 3 todd 2018-09-06 14:41:00 UTC
Thank you very much, That seems to have deleted the file.. I never realized you could force null args..