Bug 22356

Summary: mkdir
Product: Base System Reporter: unixoid <unixoid>
Component: miscAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description unixoid 2000-10-27 23:10:01 UTC
Sorry, i very bad speak english. You me that so have understood.
If folder is created with '-' at the beginning of its name then commands used in this folder take its name as parameter.

How-To-Repeat: If folder is created with '-' at the beginning of its name then commands used in this folder take its name as parameter.
Comment 1 Peter Pentchev 2000-10-27 23:17:54 UTC
On Fri, Oct 27, 2000 at 03:05:36PM -0700, unixoid@pisem.net wrote:
> >Number:         22356
> >Category:       misc
> >Synopsis:       mkdir
[snip]
> >Description:
> Sorry, i very bad speak english. You me that so have understood.
> If folder is created with '-' at the beginning of its name then commands used in this folder take its name as parameter.
> >How-To-Repeat:
> If folder is created with '-' at the beginning of its name then commands used in this folder take its name as parameter.

Why don't you give some examples?  Like the mkdir command, the commands you
are trying to execute after that, and such?

But first, a question - are you trying to execute commands *in* that directory,
or *on* it?  I mean, if you have created a dir named 'test',
are you doing e.g. 'cd test; ls' or are you trying to do 'ls -test'?

If it is "ls -test" that is bugging you, then have you tried putting '--'
immediately before the directory name, as in 'ls -- -test'; '--' is
the traditional (GNU originated, I think) way of separating a command's
flags from its other parameters, so getopt() and similar functions do not
try to parse the parameters starting with '-' as options.

G'luck,
Peter

-- 
If I had finished this sentence,
Comment 2 brooks 2000-10-27 23:22:55 UTC
On Fri, Oct 27, 2000 at 03:05:36PM -0700, unixoid@pisem.net wrote:
> If folder is created with '-' at the beginning of its name then
> commands used in this folder take its name as parameter.

This is not a bug.  UNIX file names can contain dashes and they may
appear any where in a file name.  Well written programs support the "--"
arguemnt to signal that any further arguments should not be parsed as
options.  For example "mkdir -- -blah; rmdir -- -blah" works just fine.

If you find dealing with such files annoying, don't create such files.
To quote Terry Lambert:

If you aim the gun at your foot and pull the trigger, it's UNIX's job to
ensure reliable delivery of the bullet to where you aimed the gun (in this
case, Mr. Foot). -- Terry Lambert, FreeBSD-Hackers mailing list.

-- Brooks

-- 
Any statement of the form "X is the one, true Y" is FALSE.
Comment 3 Salvo Bartolotta 2000-10-28 00:57:06 UTC
>>>>>>>>>>>>>>>>>> Original Message <<<<<<<<<<<<<<<<<<

On 10/27/00, 11:05:36 PM, unixoid@pisem.net wrote regarding
misc/22356: mkdir :


> >Number:         22356
> >Category:       misc
> >Synopsis:       mkdir
> >Confidential:   no
> >Severity:       serious
> >Priority:       medium
> >Responsible:    freebsd-bugs
> >State:          open
> >Quarter:
> >Keywords:
> >Date-Required:
> >Class:          change-request
> >Submitter-Id:   current-users
> >Arrival-Date:   Fri Oct 27 15:10:01 PDT 2000
> >Closed-Date:
> >Last-Modified:
> >Originator:     JIaMaK
> >Release:        FreeBSD 4.1
> >Organization:
> home
> >Environment:
> FreeBSD 4.1
> >Description:
> Sorry, i very bad speak english. You me that so have understood.
> If folder is created with '-' at the beginning of its name then
commands used in this folder take its name as parameter.



Dear Sir or Madam,

I am afraid I am missing your point.


>=3D=3D=3D=3D> mkdir -- -trial   # create the -trial directory

# ls -l lists, inter alia, the -trial directory.

>=3D=3D=3D=3D> cd "-trial"       # let's cd to -trial

>=3D=3D=3D=3D> pwd               # where are we ?
/usr/home/[...]/-trial

>=3D=3D=3D=3D> touch mywildtrial # let's touch(1) a file
263 12:36am ~/-trial >=3D=3D=3D=3D> ll # "ls -l" in tcsh shell
total 0
-rw-r--r--  1 [...]  0 Oct 28 00:36 mywildtrial

>=3D=3D=3D=3D> vi mywildtrial

/* I write the sentence "The quick brown computer jumped over the
seven lazy users" (cf vilearn, in the ports collection :-) and then
save the file. */

>=3D=3D=3D=3D> ll

265 12:37am ~/-trial >=3D=3D=3D=3D> ll
total 1
-rw-r--r--  1 [...]  58 Oct 28 00:37 mywildtrial

>=3D=3D=3D=3D> mkdir -- -nestedtrial # A little baroque...

265 12:37am ~/-trial >=3D=3D=3D=3D> ll
total 2
drwxr-xr-x  2 [...] 512 Oct 28 00:43 -nestedtrial
-rw-r--r--  1 [...]  58 Oct 28 00:37 mywildtrial


I don't normally create such things; this is just an extemporaneous
exercise :-)

What commands are you referring to ?

Best regards,
Salvo
Comment 4 mpp freebsd_committer freebsd_triage 2000-10-28 19:18:44 UTC
State Changed
From-To: open->closed

This is a case of user error. 

When trying to create or manipulate files or directories, you 
need to prevent the utility in question from interpreting the 
file name as an option.  In this case, the following would work: 

mkdir -- -test 
or 
mkdir ./test 
or 
mkdir /full/path/-test 

See the FAQ at www.freebsd.org for more information on common 
questions like this.