Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ocamlbuild -build-dir dangerous behaviour #5996

Closed
vicuna opened this issue Apr 22, 2013 · 6 comments
Closed

ocamlbuild -build-dir dangerous behaviour #5996

vicuna opened this issue Apr 22, 2013 · 6 comments

Comments

@vicuna
Copy link

vicuna commented Apr 22, 2013

Original bug ID: 5996
Reporter: william
Status: resolved (set by @damiendoligez on 2017-02-24T15:29:56Z)
Resolution: suspended
Priority: normal
Severity: minor
Platform: Linux
Version: 4.00.1
Target version: later
Category: -for ocamlbuild use https://github.com/ocaml/ocamlbuild/issues
Monitored by: @gasche @hcarty

Bug description

I run this command :
ocamlbuild -build-dir ../../toto ..
which did not work

  • mkdir /home/william/tmp/test/test2/..
    mkdir: impossible de créer le répertoire « /home/william/tmp/test/test2/.. »: Le fichier existe
    Command exited with code 1.
    Failure:
    Error during command "mkdir /home/troit/tmp/test/test2/..": My_std.Exit_with_code(10).

then I did this :
ocamlbuild -build-dir '/svn/build'
which created the directory '
' in the repository where I executed ocamlbuild

Then I wanted to remove the directory :
rm -Rf ~

:-|
Don't explain you what the problem is. Felt like a newbe

@vicuna
Copy link
Author

vicuna commented Jul 29, 2013

Comment author: @ygrek

PEBKAC, ocamlbuild behaviour is correct.
Passing '' inside single quotes precludes its expansion by the shell, and tells ocamlbuild to use literally the '' directory, instead of $HOME, exactly what happened.
You probbably want to use "~" (inside double quotes). Read 'man bash' for shell quoting rules before using the shell.

@vicuna
Copy link
Author

vicuna commented Jul 29, 2013

Comment author: william

ah ah.
ok, but let's try to isolate things :

  1. make ../foo works,
    but ocamlbuild -build-dir ../foo does not work

  2. make '/foo' does not work (and does not create a folder named '')
    but ocamlbuild -build-dir '/foo' creates directory '' (becareful, do not launch this command unless you know how to remove '~' without removing your home directory :-), which I don't, so will not try it again)

  3. make "/foo" works (thanks ygrek for the explanation about " and ')
    but ocamlbuild build-dir "
    /foo" creates directory '' (and subfolders) inside the directory, as subdirectories without expanding ''.

and '~' can be removed by doing :
rmdir ~
:-)

@vicuna
Copy link
Author

vicuna commented Jul 29, 2013

Comment author: william

for information, there is no big deal with all this, there may be more important things. also, it was quite clear in the doc that build dir was to be local.

@vicuna
Copy link
Author

vicuna commented Jul 29, 2013

Comment author: @gasche

There are some difficulties with absolute vs. relative paths in various places in OCamlbuild. This precise issue is at least a case of confusing user interface.

@vicuna
Copy link
Author

vicuna commented Feb 24, 2015

Comment author: @damiendoligez

FTR, '' and "" do the exact same thing under bash.

Maybe we should special-case ~ in the -build-dir code (and signal an error) to avoid confusing the users. Anyone who really wants a directory called ~ can just use ./~

@vicuna
Copy link
Author

vicuna commented Feb 24, 2017

Comment author: @damiendoligez

ocamlbuild is now a separate project that lives on GitHub.
PR transferred to ocaml/ocamlbuild#158

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant