Close

bash aliases WHOOPS

A project log for PotentiallyUseful/Frustrating/Obscure C/GCC/Make

Notes about unexpected findings in C/GCC... (and Make, and plausibly Bash, etc.)

eric-hertzEric Hertz 02/27/2017 at 16:480 Comments

I can't believe I've never run into this before...

I've had this in my .bash_profile for *years*

alias mmv='echo "" ;  echo "DON'\''T GET COCKY! mv -i set in .bash_profile, this is NOT default. " ;  echo "  Default is to overwrite WITHOUT PROMPTING" ;  echo "" ;  /bin/mv -i'

Now I did:

diff file1 file2 && mmv file1 otherDir

-----------

Now, apparently, 'alias' doesn't act like a script or a function, as I'd long-understood.

Apparently it literally just pastes the contents on the line... so what I'm getting, instead is essentially:

diff file1 file2 && echo "" ; ..... ; mv file1 otherDir

I have a *really* hard time believing I never ran into this before. REALLY hard time. Literally *years* I've used this alias... and never *once* ran into this?! But, that's the claim.

So, those ';'s need to be replaced with '&&'.

-----------

And upon looking at the alias with fresh eyes, I should've seen that it wasn't treated like a function... since it's not using arguments...

Discussions