Created
December 31, 2011 15:03
-
-
Save wolframkriesing/1544236 to your computer and use it in GitHub Desktop.
find vs. exec(find)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
me@localhost:~> find /Applications/ -iname *.plist | wc -l | |
6660 | |
me@localhost:~> node -e "require('child_process').exec('find /Applications/ -iname *.plist', function(_, stdout){ console.log(stdout.split('\n').length) })" | |
1806 | |
// Why does the same find ran on the cmdline return a different number than when used via exec in node? | |
// Found the bug | |
// This works: | |
me@localhost:~> node -e "require('child_process').exec('find /Applications/ -iname *.plist', {maxBuffer:10000*1024}, function(_, stdout){ console.log(stdout.split('\n').length) })" | |
6661 | |
me@localhost:~> find /Applications/ -iname *.plist | wc -l | |
6660 |
the maxBuffer argument determines the buffer size and therefore the result are only reported as they fit in there
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
good idea, i found the bug:
node -e "require('child_process').exec('find /Applications/ -iname .plist', {maxBuffer:10000_1024}, function(, stdout){ console.log(stdout.split('\n').length) })"
does work properly!!!