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

mkdir fails with non-normalized path #634

Closed
webOS101 opened this issue Dec 20, 2016 · 1 comment
Closed

mkdir fails with non-normalized path #634

webOS101 opened this issue Dec 20, 2016 · 1 comment
Assignees
Labels
fix Bug/defect, or a fix for such a problem medium priority
Milestone

Comments

@webOS101
Copy link

webOS101 commented Dec 20, 2016

Node version (or tell us if you're using electron or some other framework): v6.8.0

ShellJS version (the most recent version/Github branch you see the bug on): 0.7.5

Operating system: Mac

Description of the bug: Shell js exits with Error: EEXIST: file already exists when mkdir path is not normalized. You cannot trap this with a try/catch block.

Example ShellJS command to reproduce the error:

shelljs = require('shelljs');
shelljs.mkdir('-p', 'asdf/./');

Expected result is that no error should be thrown and certainly the process should not terminate. '-p' flag should not fail for any existing path or part of path.

@nfischer nfischer self-assigned this Dec 20, 2016
@nfischer nfischer added fix Bug/defect, or a fix for such a problem medium priority labels Dec 20, 2016
@nfischer
Copy link
Member

@webOS101 Thanks for reporting. It looks like most of our utilities should probably normalize paths before using them. I'll work on a fix for this tonight using path.resolve().

It looks to me like most commands would want paths to be resolved before handling them (ln() is an example of where this is not the case). I'll wrap this functionality as a default part of common.wrap (ln() will opt-out), although this probably only affects mkdir -p, cp -r, and rm -r, and ls -R (anything recursive).

To address your second concern, where the process dies, this will be fixed when we release v0.8. See #483.

@nfischer nfischer added this to the v0.7.x milestone Dec 20, 2016
nfischer added a commit that referenced this issue Dec 21, 2016
Adds tests to make sure that non-normalized paths (i.e. path/to/./dir) are
valid for a few commands, including mkdir() which previously failed when given
the -p flag.

Fixes #634
freitagbr pushed a commit that referenced this issue Jan 8, 2017
Adds tests to make sure that non-normalized paths (i.e. path/to/./dir) are
valid for a few commands, including mkdir() which previously failed when given
the -p flag.

Fixes #634
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Bug/defect, or a fix for such a problem medium priority
Projects
None yet
Development

No branches or pull requests

2 participants