When I try to combine two normal commands using the ; character (eg. ls; cd) it works fine. However, I have two aliases that I've created (stopdev and startdev), and if I try to combine them:
stopdev; startdev
or even if I just try and add a semi-colon after one:
stopdev;
I get a syntax error:
bash: syntax error near unexpected token `;'
I also have the same problem if I use &&:
stopdev && startdev
bash: syntax error near unexpected token `&&'
I'm confused by this because I had thought that aliases were just like any other commands ... but clearly they aren't.
So, two questions:
- Why is using
;or&&with an alias call invalid? - Is there any way (other than creating a
stopstartdevalias) to easily run these two commands together?
Here's the definition of stopdev:
alias stopdev="cd $HOME/website; make website_stop; make backend_stop;"
alias a="echo foo"; alias b="echo bar"; a; b. Does that work?stopdev, what does the alias do ? I created 2 aliases to 2 simple commands and it works fine with a semicolon in between themalias stopdev="cd $HOME/website; make website_stop; make backend_stop;". I think we've found the problem. If either of you want to provide an answer to the effect of "it's because your alias has a semi-colon at the end of its definition, dummy" I'll be happy to accept it.make backend_stopcommand, as noted in @Gilles' answer.