Skip to content

Instantly share code, notes, and snippets.

@mcculloughsean
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcculloughsean/10076296 to your computer and use it in GitHub Desktop.
Save mcculloughsean/10076296 to your computer and use it in GitHub Desktop.
Bug with cp.spawn and
var cp = require('child_process'),
util = require('util');
var env = {}; //util._extend({}, process.env);
env.MY_AWESOME_ENV_VAR = 'hello world!';
var inheritCp = cp.spawn('./test.sh', undefined, {env: env});
inheritCp.stdout.pipe(process.stdout);
☁ node-cp-spawn node --version
v0.10.24
☁ node-cp-spawn node node-spawn.js
Hello world!
MY_AWESOME_ENV_VAR=hello world! PWD=/Users/mccullough/dev/tmp/node-cp-spawn SHLVL=1 _=/usr/bin/env
☁ node-cp-spawn
☁ node-cp-spawn node --version
v0.10.26
☁ node-cp-spawn node node-spawn.js
Hello world!
GREP_COLOR=1;32 TERM_PROGRAM=iTerm.app SSL_CERT_FILE=/usr/local/opt/curl-ca-bundle/share/ca-bundle.crt TERM=xterm-256color SHELL=/bin/zsh TMPDIR=/var/folders/y7/_xxsjpb53910_k3yv7vrrggh0000gn/T/ Apple_PubSub_Socket_Render=/tmp/launch-TOpjry/Render USER=mccullough RBENV_ROOT=/Users/mccullough/.rbenv SSH_AUTH_SOCK=/tmp/launch-So0T43/Listeners __CF_USER_TEXT_ENCODING=0x1F5:0:0 PAGER=less LSCOLORS=Gxfxcxdxbxegedabagacad __CHECKFIX1436934=1 PATH=./node_modules/.bin:/Users/mccullough/.rbenv/bin:/Users/mccullough/bin:/usr/local/n/current/bin/:/usr/local/bin:/usr/local/share/python:/Users/mccullough/.rbenv/shims:/Users/mccullough/.rbenv/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/mccullough/go/bin PWD=/Users/mccullough/dev/tmp/node-cp-spawn LANG=en_US.UTF-8 ITERM_PROFILE=Default SHLVL=2 COLORFGBG=7;0 HOME=/Users/mccullough GOROOT=/Users/mccullough/go GREP_OPTIONS=--exclude-dir=.cvs --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --color=auto ITERM_SESSION_ID=w0t4p1 LESS=-R LOGNAME=mccullough LC_CTYPE=en_US.UTF-8 SECURITYSESSIONID=186a4 _=/usr/bin/env
#!/bin/sh
echo "Hello world!"
echo `env`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment