News for hackers. Stuff that matters.
Re:CoreUtils implemented in pure JavaScript by pjc50 on Tuesday March 22, 2016 @12:29PM (#11337713)
I keep wanting to like PowerShell but finding it limited in silly ways. Text output is crippled, and there's no sensible way to save the intermediate value of a pipeline in a file.

The security ceremony required around PS is also an obstacle to getting started. And of course Microsoft have missed the opportunity to fix the path separator.

I admit that Bourne shell is not great for anything over a few lines, and find it better to drop into perl or python where filename-separator issues are mostly eliminated.

Re:CoreUtils implemented in pure JavaScript by dsp1234 on Tuesday March 22, 2016 @12:39PM (#11337773)
and there's no sensible way to save the intermediate value of a pipeline in a file

Sounds like you are looking for Tee-Object[0].

"Saves command output in a file or variable and also sends it down the pipeline."

And of course Microsoft have missed the opportunity to fix the path separator.

Windows supports both path separators in pretty much all cases (open files, changing directories, etc)

  PS C:\> d:
  PS D:\> cd /projects/node_modules/immutable/node_modules/uglify-js/node_modules
  PS D:\projects\node_modules\immutable\node_modules\uglify-js\node_modules>
Text output is crippled

I guess this depends on what you want out of the system. Some options are:

"format-table -auto" which provides a nicely formatted table view of the data

"format-list" which provides each property on a separate line with a blank line between objects

"format-custom" which allows you to create your own views of objects (with a very readable default), which has ultimate flexibility

"converto-csv" which output the object as a CSV (or with custom delimiters such as TSV)

"converto-html" which outputs the object as an html table (with somewhat customizable markup)

"convertto-xml" similar to the above

But really, if it's possible, then it makes sense to use the object pipeline until you're done (so that different parts of the pipeline can use different parts of the object). Then spitting out CSV, TSV, XML, etc should get interop with basically every other tool that's going to process text in some way.

[0] - https://technet.microsoft.com/en-us/library/hh849937.aspx

Re:CoreUtils implemented in pure JavaScript by pjc50 on Tuesday March 22, 2016 @05:56PM (#11340266)
Text output is chopped at 80 characters unless you specify otherwise, even when directed to a file; I'm probably going to try converto-csv next time I want to input it into python, thanks for the tip.

The output of tee-object can't easily be read back in to a new pipeline. I suppose we're supposed to stash it in a variable which will be good enough for 99% of cases.