DEV Community

Discussion on: $ considered harmful

Collapse
 
moopet profile image
Ben Sinclair

I've pondered this myself. I use it in embedded scripts-that-aren't exactly scripts. Stuff where I'm giving an example of what something will do when run.

For example, in a recent post I had something like this:

$ pwd
/home/moopet

$ echo $$
8192

I don't want to have to explain what I'm doing every time, and $ is a kinda convention, but I'm also slightly concerned that it might confuse people who haven't seen it before.

As far as presenting literal lines as a series of instructions, I think we should leave it out. Not so that people can copy-paste the whole script, though! We should encourage people to try one line at a time, because these little formulae, even with the best intention, will explode your machine one day from a casual assumtpion:

cd /tmp/foo
rm -rf *

In the real world, we'd want to at least separate those commands with && or something, in case /tmp/foo doesn't exist.

So I think any argument for copying snippets small enough for tweets is probably invalid.