47 points · by andreygrehov · 12y ago · 36 comments
Well, no, not when you're piping ls into it. That's what --null (or -0) is for. (Use find instead.) The man page offers a similarly baffling argument:
> xargs deals badly with special characters (such as space, ' and "). To see the problem try this:
touch important_file
touch 'not important_file'
ls not* | xargs rm
mkdir -p "My brother's 12\" records"
ls | xargs rmdir
Same problem as the article: piping in the output of ls into xargs.> You can specify -0 or -d "\n", but many input generators are not optimized for using NUL as separator but are optimized for newline as separator.
I still don't see the argument: if the generator is "optimized for newline as a separator", then -d is what you need. But if your generator is outputting a list of file names (perhaps the most common case of xargs), then -0 is what you need. It is perhaps somewhat unfortunate that its use of whitespace (and bash's use) make it so easy to write subtly incorrect programs; this is perhaps why there's such common advice to use Python, or anything not Bash. But the argument above leads me to think that `ls | parallels` would somehow work, which it cannot, for the very reasons we must use xargs -0.
I suspect this is a long way about saying "we have (somewhat more, but still not quite) sane defaults".
The correct command has always been `find . not* -print0 | xargs -0 ~/code/random/args.py`. Anything else is subject to weird corner cases of failure. It's a sad state of affairs really, and I'd love to change it. If you're just pounding out a command on the command line, you can usually ignore those corner cases, as you probably mentally know whether `ls not*` is going to cause issues or not; if you're writing a script for general use, then it's only a matter of time until it fails in interesting ways.
If you need to be portable, you can do pretty well with
find ... | sed 's/./\\&/g' | xargs command
This will only break with filenames that have newlines in them.Sometimes by playing with the -j or xargs --max-procs you discover interesting bottlenecks. Remember spending time trying to speed up this script. Used the make trick, it still was not running fast enough, it turns out disk i/o was the bottleneck.
target: dep1 dep2 then dep1 and dep2 might be executed in parallel if -j>1
There are not many make expert (I am not one) so looking and figuring out the issue is sometimes tricky so often I see -j1 used always by default.
http://stackoverflow.com/questions/356100/how-to-wait-in-bas...
Should we ban kukuruku.co? There's good content (if not good English) in the articles, but these tactics are sleazy and it doesn't feel like behavior HN should be involved in encouraging.
https://news.ycombinator.com/item?id=7770909
https://news.ycombinator.com/item?id=7770887
https://news.ycombinator.com/item?id=7770727
https://news.ycombinator.com/item?id=7768391
https://news.ycombinator.com/item?id=7765671
https://news.ycombinator.com/item?id=7764938
https://news.ycombinator.com/item?id=7763187
https://news.ycombinator.com/item?id=7753792
https://news.ycombinator.com/item?id=7753166
https://news.ycombinator.com/item?id=7741937
https://news.ycombinator.com/item?id=7734202
https://news.ycombinator.com/item?id=7732049
It's awkward, but in the end, I lean toward keeping them here, promoting their translations, and encouraging them to give clear credit to the original authors. While banning them might feel right, I fail to see it making the world a better place. I think it's better in the end to keep them here and gradually encourage them to improve their ways.
They are stealing content.
Another user (leephillips) posted the following about their posts: "I went to the site and left a comment complaining about how they stole your article. They deleted the comment, and you still aren't credited. Does HN have a blacklist of sites that steal content or publish only blogspam? I think they should consider it." - https://news.ycombinator.com/item?id=7754641
I do agree that you are providing a useful service by spreading high quality technical information. My understanding is that unauthorized translations are more common and more tolerated in Russia than in the US. But HN is a very law-abiding business-oriented site, and justifiably is concerned with following the law. Thanks for signing up here to explain, and please try to work with DanG to come up with a plan.
"Пользователь осознаёт и соглашается с тем, что размещённая им информация может быть использована поисковыми или другими автоматизированными сервисами и иными способами."
Here is the translation:
"User acknowledges and agrees that the uploading of such information can be used by search engines or other automated services, and in other ways."
But anyway, we will get in touch with authors. We'll try to find that out.
DanG: let me know if you guys have any other concerns. Do you want us to specify the link to author's habrahabr profile in addition ?
Also, what about asking authors for permission to translate and republish their work?
I would definitely support a ban in this case but at the same time I think there is a need for properly accredited translations (good ones, not crappy ones like these where according to one of the authors lots of nuance got lost) of good content found on non English language websites.
Maybe this is something the people behind Hacker News Magazine could look into, they seem to have the right attitude when it comes to re-using content.
Please, don't spread rumors. What crappy translations are you specifically talking about ?