This morning, I posted M Tang`s funny experiment in feeding the Unix "yes" command to itself. Now, Seth David Schoen writes in to correct and expand upon the principles therein:
M. Tang`s business about the Unix command
yes `yes no`
is based on a bit of a misconception. The problem is _not_ about
combining one yes command with another yes command. Whenever you use
the backtick syntax `, like in a hypothetical command
the shell will first run the command bar (to completion) before it even
tries to start foo. The shell will also save the complete output of bar
in memory, and then present it as a set of command-line arguments to
In this case, the shell is trying to run the command "yes no" to
completion, saving its output in memory, before even starting the other
yes command. Of course, "yes no" never finishes, but it does use up
an arbitrarily large amount of memory.
To see that the problem is with the use of `yes` rather than with the
combination of two yes commands, just try
echo `yes no`
true `yes no`
Both of these forms have exactly the same memory-consumption problem as
the original command, and for exactly the same reason! So, Tang is
wrong to think that he is somehow creating a problem by combining
multiple yesses. The problem is in asking the shell to remember an
infinite amount of output.
As other people have mentioned in comments, the ` syntax is also not
piping. Piping is done with |, while ` refers to substitution. The
distinction is whether the output of program A appears as input to
program B (piping) or as command-line arguments to program B
(substitution). For example,
echo foo bar | wc -w
outputs the number 2 (that`s the total number of words in the text
"foo bar"), while
wc -w `echo foo bar`
counts the number of words in the files foo and bar.
States across America are considering “Right to Repair” legislation that would guarantee your right to choose who fixes your stuff (or to fix it yourself); but they’re fighting stiff headwinds, from the motorcycle makers who claim that fixing your motorcycle should be a crime to Apple, who feel the same way, but about phones.
“Stephen Colbert” is a character that was once played by Stephen Colbert: a right-wing blowhard pundit who called Bill O’Reilly “Papa Bear.” When Colbert took over the Late Show, the “Stephen Colbert” character disappeared (possibly because Viacom claimed the rights to it!), but now and again, he reappears.
Kvatch of The Hoax Hotel is masterful at playing rubes who fall for online scams. In this gem, he keeps an “FBI agent” named “Josh” on the line for nearly 22 minutes, riling him up until he’s “the angriest scammer I’ve ever called.”
The Lightning port has thus far resisted the cruel fate that befell the headphone jack, and despite rumors that it may be disappearing come iPhone 8, for the present and foreseeable future, Lightning cables are a hot commodity for iPhone users. As such, we must make do in this strange time in which long, glorified […]
All the filters in the world won’t save your smartphone pics from a shaky hand. To really step up your mobile photography game, you’ll need some kind of mount to hold it steady. You could buy a smartphone attachment for a conventional camera tripod, but who wants to carry that kind of gear everywhere they […]
The forced transition from analog to digital TV signals was probably met with relative indifference from people with Netflix subscriptions and the “I don’t even own a TV” snoots. But anyone living in the vast swaths of the country that don’t have guaranteed high-speed internet, broadcast TV is a perfectly valid (and 100% free) way […]