-
Notifications
You must be signed in to change notification settings - Fork 44
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
Discuss: popd/pushd workarounds #121
Comments
You can try this out at home: $ cat my-cd-script.js
var shell = require('shelljs');
shell.cd('foo');
$ pwd && node my-cd-script.js && pwd # the cd() can't affect your shell's directory |
I'm well aware, but we're talking about
My point is that the same holds for pushd and popd. They're commands that work on both Windows and Unix, just like Of course, none of this has anything to do, strictly, with ps. unrelated sidenote: on Windows (and not on UNIX, afaik) it is actually possible to change the parent process's working directory, in some cases, using a hack driven by batch files. It works because batch files don't actually spawn a child environment but run in the context of the environment that invokes them. I once used this in a little hobby project: https://github.com/eteeselink/cdhere |
Ah ok, this is news to me. If this is the case, then I agree that we should list them as workarounds just like
Are double quotes required? This stackoverflow seems to indicate that Windows
Right 😄 Wouldn't this be considered running in the same process though? On Unix, you can |
PR made! About the side-note: yep! effectively, invoking a batch file on Windows works like sourcing a script on Unix. The thing is that this means that you could implement cd, popd, pushd and dirs inside shx on Windows. As long as the Not that I think there is any value to that, given that cd, pushd and popd work cross-platform. Plus I don't think there's a way to make it cross-platform. I'm really just rambling here :-) |
Anything's possible if you change the project 😜 In our case, we're a node module, so that will always run under a separate process. |
Well, shx is a node module started by a batch file on Windows :-) (node_modules/.bin/shx.cmd to be precise). But anyway, the point is moot because, a) we can't do the same on UNIX and b) there's no use because |
Fixed by #122 |
The README says that popd and pushd can't be used and don't have a workaround, but for many basic cases there is: Windows accepts forward slashes when you quote the path. So:
works the same on Windows and *nix. I'm not sure how well it'd work with expanding environment variables though, but I bet that for basic package.json oneliners you often don't need that.
Was this unknown knowledge, or is there a reason I'm not aware of why popd and pushd are shown to have no workarounds?
The text was updated successfully, but these errors were encountered: