shelljs/shx

pushd not found on linux

brunolemos opened this issue ยท 6 comments

Any reason why not alias pushd to cd and popd to cd -? They seem to have the same behavior and cd - works great on linux (ubuntu at least).

Note: I did see the readme table and the other issue.

cd, pushd, and cd - all behave a little differently, so aliasing wouldn't really be correct.

The broader issue is we can't implement any of these in shx. These work by modifying the current working directory, which is just an environmental variable. However, shx runs in a subprocess, so it can't modify the calling shell's environment.

pushd not found on linux

Not sure what you mean. pushd is a shell builtin in bash, and you should have bash installed on your Linux system.

I'm currently unable to use popd of pushd in my github actions commands, even when I set my shell to cmd, sh or bash (It seems to always execute /bin/sh popd, although I define bash). Any workaround to have these commands available on all platforms?

I think sh may not support pushd/popd (I tested with /bin/sh on Ubuntu, which is implemented by dash). So you'll probably need bash rather than sh. I don't know which shells Github actions supports. If Github actions supports Windows, then it should certainly support cmd.exe.

Closing this because I don't think shx needs to make any changes here, but feel free to keep discussing.

Yeahh I tried cmd and bash as shell in my github actions, but it still continued to use /bin/sh.
Anyway, it's probably an issue related to github actions itself.
For anyone wondering, I've used yarn to change shells (yarn config set script-shell /bin/bash) and everything is fine now.

Try this command, Yeah i know it seems to be counter intuitive. Then select no when it asks if want to use dash. You will end up with bash as yur command interpreter.

sudo dpkg-reconfigure dash

Removing 'diversion of /bin/sh to /bin/sh.distrib by dash'
Adding 'diversion of /bin/sh to /bin/sh.distrib by bash'
Removing 'diversion of /usr/share/man/man1/sh.1.gz to /usr/share/man/man1/sh.distrib.1.gz by dash'
Adding 'diversion of /usr/share/man/man1/sh.1.gz to /usr/share/man/man1/sh.distrib.1.gz by bash'

You can check it with this command

readlink -f $(which sh)
Reply should be

/usr/bin/bash