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

I can't cd after I removed a sub-folder!? #1050

Open
melroy89 opened this issue Oct 18, 2021 · 1 comment
Open

I can't cd after I removed a sub-folder!? #1050

melroy89 opened this issue Oct 18, 2021 · 1 comment
Labels
bash compat Compatibility issues with bash or POSIX behavior fix Bug/defect, or a fix for such a problem

Comments

@melroy89
Copy link

melroy89 commented Oct 18, 2021

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

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

Operating system: Linux

Description of the bug:

When I'm in the folder (via cd) that I want to remove and I executed the shell.rm() the folder. like /tmp/testfolder. I can't change the directory towards that root-folder, so in this case: shell.cd('/tmp') won't work anymore!?

Error I would get it:

cd: not a directory: /tmp
    at Object.error (/path_to_project/node_modules/shelljs/src/common.js:110:27)
    at Object._cd (/path_to_project/node_modules/shelljs/src/cd.js:35:21)
    at Object.cd (/path_to_project/node_modules/shelljs/src/common.js:384:25)

Yes, the /tmp folder still exists! So I'm 100% sure that folder is NOT removed.

Example ShellJS command to reproduce the error:

shell.cd('/tmp/a')
shell.rm('-rf', '/tmp/a')
shell.cd('/tmp')

Please, help!?

@melroy89
Copy link
Author

melroy89 commented Oct 19, 2021

The root-cause was I was actually within the directory itself, that I was going to remove.

Causing very strange behavior.

Currently my solution is to cd out of the directory I'm gonna remove. Otherwise the sh*t hit the fan.

@nfischer nfischer added bash compat Compatibility issues with bash or POSIX behavior fix Bug/defect, or a fix for such a problem labels Nov 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bash compat Compatibility issues with bash or POSIX behavior fix Bug/defect, or a fix for such a problem
Projects
None yet
Development

No branches or pull requests

2 participants