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

In mv command, there should be en error if destination directory not present. #1146

Open
gagan-bansal opened this issue Dec 27, 2023 · 1 comment
Labels
bash compat Compatibility issues with bash or POSIX behavior fix Bug/defect, or a fix for such a problem

Comments

@gagan-bansal
Copy link

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

node version: v18.17.1

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

ShellJS version: 0.8.5

Operating system:

Ubuntu 23.04

Description of the bug:

In mv command if the destination directory does not exist, the stderr should have the error message.

Example ShellJS command to reproduce the error:

On linux shell, there is an error message.

$ touch test-file.txt
$ mv test-file.txt /path/doesnot/exist/
mv: cannot move 'test-file.txt' to '/path/doesnot/exist/': No such file or directory

Javascript:

const shell = require('shelljs')
var resp = shell.mv('./test-file.txt', '/path/doesnot/exist/')
console.log(resp.stderr)
// null
@gagan-bansal gagan-bansal changed the title In mv command, there should be en error if destination not present. In mv command, there should be en error if destination directory not present. Dec 27, 2023
@nfischer nfischer added fix Bug/defect, or a fix for such a problem bash compat Compatibility issues with bash or POSIX behavior labels Dec 27, 2023
@nfischer
Copy link
Member

I agree, this should ideally return an error. Some comments about this:

  1. mv test-file.txt does-not-exist/ should throw an error because does-not-exist/ must be interpreted as a folder (due to the trialing slash). This is the case which is broken in shelljs: the behavior is actually correct (it does not copy the file), but it needs to print an error message about the issue.
  2. mv test-directory does-not-exist/ should not throw an error; test-directory is a directory, so it will be renamed to a directory named does-not-exist. This case works as expected in shelljs.
  3. mv test-file.txt other-test-file.txt does-not-exist is supposed to throw an error; if there are 3 arguments, then the last argument must be a folder which already exists. This case works as expected in shelljs.

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