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

[Feature] Shell Implementation should accept NUL (nul) as null device for redirection #4028

Closed
2 tasks
jeffrson opened this issue Jan 28, 2022 · 5 comments
Closed
2 tasks
Labels
enhancement New feature or request stale Issues that didn't get attention waiting for feedback Will autoclose in a while unless more data are provided

Comments

@jeffrson
Copy link

  • I'd be willing to implement this feature (contributing guide)
  • This feature is important to have in this repository; a contrib plugin wouldn't do

Describe the user story

yarn has a "bash like" internal shell for scripts in package.json. This shell tries to be "cross platform". As such it handles "/dev/null" to ignore standard output of commands. However, on Windows, /dev/null does not exist.
There is a need of Windows only scripts: Since there's no external or builtin cp command, "xcopy" or "cmd /c copy" must be used on Windows. It looks weird to redirect its output to /dev/null in such circumstances. Also there's no benefit (in terms of crossplatform), since the script will not work on Linux or Mac anyway.

Describe the solution you'd like

The integrated shell should use "NUL" (case independent) as an alias to /dev/null, and treat it alike.

Describe the drawbacks of your solution

There would be no way to redirect standard output/error to a file called "nul" on Linux/Mac.

Describe alternatives you've considered

None.

@jeffrson jeffrson added the enhancement New feature or request label Jan 28, 2022
@arcanis
Copy link
Member

arcanis commented Jan 28, 2022

Not sure I see the benefit? Instead of having an unexpected syntax for one system, this would just make an unexpected syntax for all systems. Additionally, we already implement the : builtin which kinda does this already, if really needed.

@arcanis arcanis added the waiting for feedback Will autoclose in a while unless more data are provided label Jan 28, 2022
@jeffrson
Copy link
Author

There's no unexpected syntax on other systems - they may use /dev/null as before.

Additionally, the trouble with NUL (as Windows users would normally use) is, that yarn (via node) creates a file called "NUL", which is cumbersome to get rid of (especially after yarn workspace foreach). I assumed this to be a bug in node, but it seems it aint: nodejs/node#33829

I'm not sure, how ":" would help here.

@yarnbot
Copy link
Collaborator

yarnbot commented Feb 27, 2022

Hi! 👋

It seems like this issue as been marked as probably resolved, or missing important information blocking its progression. As a result, it'll be closed in a few days unless a maintainer explicitly vouches for it.

@yarnbot yarnbot added the stale Issues that didn't get attention label Feb 27, 2022
@jeffrson
Copy link
Author

jeffrson commented Mar 1, 2022

It's not resolved - and feedback has been sent.

I still find it helpful to get an alias (not a platform specific replacement): this is more readable for Windows people (they might not understand why there should be /dev/null) and it would prevent creating a file NUL, which is somewhat hard to handle.

@arcanis
Copy link
Member

arcanis commented Mar 1, 2022

I'll close this as wontfix, I'm still not sure why | : or > /dev/null are unsuitable.

The NUL problem you're referencing on Windows seems like it'd only happen if you do > NUL in the first place, which I'm not sure why it'd happen given that we don't support that as a special syntax.

Finally, new syntaxes wouldn't be compatible with other package managers so, while it'd be safe to use in most scripts, they wouldn't be safe to use in postinstall scripts. Coupled with the lack of clarity in the use case, that doesn't strike me as a good idea.

@arcanis arcanis closed this as completed Mar 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request stale Issues that didn't get attention waiting for feedback Will autoclose in a while unless more data are provided
Projects
None yet
Development

No branches or pull requests

3 participants