News for hackers. Stuff that matters.
Re:Exploring CLI Best Practices by happyslobro on Tuesday October 11, 2016 @04:55PM (#12688449)
Is there a simple way to process a list of files with this restriction? Something like `ls | xargs $(my-cli < $MAGIC_XARGS_VAR > $MAGIC_XARGS_VAR)`?

I know that it could be done with a loop, but that's a little unwieldy compared to `ls | xargs my-cli`

Re:Exploring CLI Best Practices by dllthomas on Tuesday October 11, 2016 @05:43PM (#12688765)
If processing the list of files is equivalent to processing the concatenation of the list of files, then you can `ls | xargs cat | my-util`. If it is not, then as I argued in a cousin comment I think that's another good case to support accepting file names.
Re:Exploring CLI Best Practices by okdana on Tuesday October 11, 2016 @09:56PM (#12689926)
>`ls | xargs cat | my-util`

lol, this is really turning the whole 'useless use of cat' thing on its head.

Re:Exploring CLI Best Practices by LukeShu on Tuesday October 11, 2016 @11:02PM (#12690165)
`cat` is short for conCATenate. Here it is being used to concatenate files. This is the canonical useful use of cat.

The problem with that example is parsing `ls` output.

Re:Exploring CLI Best Practices by dllthomas on Wednesday October 12, 2016 @04:55AM (#12691330)
> The problem with that example is parsing `ls` output.

Yeah, I left that alone to keep things simpler and was assuming `ls` was simply being used as short-hand for "some unspecified approach to outputting file names". In a context where hard-to-handle filenames are possible, you'd of course need to do something a little more robust.

Re:Exploring CLI Best Practices by okdana on Wednesday October 12, 2016 @03:10AM (#12690923)
Yes, that's what i was getting at. The use of `cat` isn't useless (for once) — the use of `ls` and `xargs` is.
Re:Exploring CLI Best Practices by marvy on Tuesday October 11, 2016 @11:31PM (#12690265)
so, how to avoid parsing ls? maybe use cat *, or something?
Re:Exploring CLI Best Practices by LukeShu on Wednesday October 12, 2016 @12:26AM (#12690421)
It really depends on what you are trying to accomplish.

`cat -- *` might be the right choice. Maybe `find . -maxdepth 1 -type f -exec cat -- {} +`