Hacker News new | ask | show | jobs
by IanCal 3579 days ago
If anyone wonders why this is taking too long, you may have done the same daft thing I just did, which was to copy the first command and then copy pbpaste | sh -. The latter will of course create an infinite loop.
1 comments

Why would copying two strings to the clipboard lead to an infinite loop?
If you have `pbpaste | sh -` on your clipboard and then paste it into a terminal, it'll continually execute itself.

(`pbpaste | sh - | pbpaste | sh - | pbpaste | sh - | ... | pbpaste | sh -`)

It won't, but running

    pbpaste | sh -
Means it's taking whatever is in my clipboard and executing it.

I had replaced what I wanted to execute with just "pbpaste | sh -"

So it passed "pbpaste | sh -" to the sh to run. Which would have then taken "pbpaste | sh -" and passed it to sh to run, which ...

I believe it would the same as this I think?

  pbpaste | sh - | sh - ...