title: Python subprocess stdout truncated by env variable $COLUMNS
body: <p>I am calling a bash script in python (3.4.3) using subprocess:</p>
  
  <pre><code>import subprocess as sp
  res = sp.check_output("myscript", shell=True)
  </code></pre>
  
  <p>and <strong>myscript</strong> contains a line:</p>
  
  <pre><code>ps -ef | egrep somecommand
  </code></pre>
  
  <p>It was not giving the same result as when <strong>myscript</strong> is directly called in a bash shell window. After much tinkering, I realized that when <strong>myscript</strong> is called in python, the stdout of "ps -ef" was truncated by the current $COLUMNS value of the shell window before being piped to "egrep". To me, this is crazy as simply by resizing the shell window, the command can give different results!</p>
  
  <p>I managed to "solve" the problem by passing <strong>env</strong> argument to the subprocess call to specify a wide enough COLUMNS:</p>
  
  <pre><code>res = sp.check_output("myscript", shell=True, env={'COLUMNS':'100'})
  </code></pre>
  
  <p>However, this looks very dirty to me and I don't understand why the truncation only happens in python subprocess but not in a bash shell. Frankly I'm amazed that this behavior isn't documented in the official python doc unless it's in fact a bug -- I am using python 3.4.3. What is the proper way of avoiding this strange behavior?</p>