shelljs/shx

env command

Closed this issue · 3 comments

I wish to convert this verbose command:

cross-env FOO=foo BAR=bar shx command

to this:

shx env FOO=foo BAR=bar command

Can you give a concrete example? Most shelljs commands do not examine environmental variables, and it's not clear which case you're actually hitting.

@nfischer I think you misunderstand.

Most shelljs commands do not examine environmental variables

I don't need shelljs commands to read environment variables, I need a shelljs command that sets an environment variable and spawns a subprocess with that new environment variable (similar to UNIX's env command).

For example:

shx env FOO=foo BAR=bar node -p 'console.log(process.env.FOO, process.env.BAR)'

should print foo bar.

Also, UNIX's env without any arguments would print all environment variables (so yeah, it does read).

We only support executing ShellJS commands (so it wouldn't matter if we set env vars, those shelljs commands wouldn't use them for anything).

I believe this is a duplicate of #127.