Bug 102621

Summary: Directory name or file name staring with '-' cannot be handled through command line,i.e.,terminal
Product: File System Reporter: Saptarshi Nag (saptarshinag620)
Component: ext2Assignee: fs_ext2 (fs_ext2)
Status: RESOLVED INVALID    
Severity: normal CC: mfo, sandeen, tytso
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 3.16.7-21-desktop Subsystem:
Regression: No Bisected commit-id:

Description Saptarshi Nag 2015-08-10 16:31:27 UTC
Firstly,one cannot create a directory or a file through command-line with its name starting with '-'. That is one cannot give command like 'mkdir -test' or 'touch -test' where '-test' is the directory name and file name respectively.But in other way,one can easily create or work with such directory or file in GUI,but that file or directory cannot be accessed or handled through command-line.It has been tested in Suse Linux and Ubuntu,maybe it is universal bug for linux
Comment 1 Eric Sandeen 2015-08-10 17:36:31 UTC
Not a bug, kernel or otherwise.  You're simply seeing mkdir & touch interpret "-t" as an option.  Preface with "./" to avoid this:

[sandeen@sandeen ~]$ mkdir ./-testdir
[sandeen@sandeen ~]$ cd ./-testdir
[sandeen@sandeen -testdir]$ pwd
/home/sandeen/-testdir
[sandeen@sandeen -testdir]$ touch ./-test
[sandeen@sandeen -testdir]$ ls -l
total 0
-rw-rw-r--. 1 sandeen sandeen 0 Aug 10 12:34 -test
Comment 2 Saptarshi Nag 2015-08-10 18:07:33 UTC
Hi Eric,thanks for explaining this,it works now
Comment 3 dmsfuddid 2020-10-05 20:56:18 UTC
Created attachment 292835 [details]
attachment-23156-0.html

unsubscribe linux-ext4

2015년 8월 10일 (월) 오후 6:38, <bugzilla-daemon@bugzilla.kernel.org>님이 작성:

> https://bugzilla.kernel.org/show_bug.cgi?id=102621
>
>             Bug ID: 102621
>            Summary: Directory name or file name staring with '-' cannot be
>                     handled through command line,i.e.,terminal
>            Product: File System
>            Version: 2.5
>     Kernel Version: 3.16.7-21-desktop
>           Hardware: All
>                 OS: Linux
>               Tree: Mainline
>             Status: NEW
>           Severity: normal
>           Priority: P1
>          Component: ext2
>           Assignee: fs_ext2@kernel-bugs.osdl.org
>           Reporter: saptarshinag620@gmail.com
>         Regression: No
>
> Firstly,one cannot create a directory or a file through command-line with
> its
> name starting with '-'. That is one cannot give command like 'mkdir -test'
> or
> 'touch -test' where '-test' is the directory name and file name
> respectively.But in other way,one can easily create or work with such
> directory
> or file in GUI,but that file or directory cannot be accessed or handled
> through
> command-line.It has been tested in Suse Linux and Ubuntu,maybe it is
> universal
> bug for linux
>
> --
> You are receiving this mail because:
> You are watching the assignee of the bug.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
Comment 4 Mauricio Faria de Oliveira 2020-10-06 13:23:58 UTC
(In reply to Eric Sandeen from comment #1)
> Not a bug, kernel or otherwise.  You're simply seeing mkdir & touch
> interpret "-t" as an option.  Preface with "./" to avoid this:

One can also use '--' to stop parsing for options, e.g.,

$ touch -- -test

$ mkdir -- -test-dir

$ ls -1d -- -test*
-test
-test-dir
Comment 5 Theodore Tso 2020-10-06 15:53:08 UTC
(Note that this bug is five years old, and was closed years ago.  The only reason why it got activity recently is because a spammer tried to upload a malware / phishing attachment to kernel bugzilla.)