Skip to content

Problems getting code, stdout, stderr #715

@jyunming-chen

Description

@jyunming-chen

Node version (or tell us if you're using electron or some other framework):

node v.6.9.1

ShellJS version (the most recent version/Github branch you see the bug on):

(most recent)

Operating system:

windows 10

Description of the bug:

// simple c++ files to compute factorial
// with prints to stderr & stdout, and exit codes
//
#include <stdio.h>
#include <stdlib.h>

int factorial(int n)
{
if (n == 1)
return 1;
else
return n*factorial(n-1);
}

int main(int argc, char *argv[]) {

fprintf (stderr, "test");

if ( argc != 2 ) {
	fprintf (stdout, "0\n");
	exit(1);
}else {
	fprintf (stdout, "%d", factorial( atoi(argv[1]) ) );
	exit(0);
}

}

Example ShellJS command to reproduce the error:

// as simple as this ...
//
var shelljs = require('shelljs');

shelljs.exec('./factorial.exe ' + 5, function(code, stdout, stderr) {
console.log('code: ' + code);
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
});

///////////////////////////////////////////////////////////////////////////////////////
Get this weird result

$ node main-win.js
'.' ���O�����Υ���R�O�B�i���檺�{���Χ妸�ɡC
code: 1
stdout:
stderr: '.' ���O�����Υ
���R�O�B�i���檺�{���Χ妸�ɡC

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions