0

Here is my alias.

alias myAlias='myScript --option& && exit'

I want to run the script myScript with option option in background and then exit from bash. I want to set it up as an alias called myAlias in my bashrc file. However, I am getting an syntax error when I try to run myAlias. How to fix it?

Thanks

8
  • 1
    nohup myScript --option& exit – Satō Katsura Feb 14 '17 at 9:59
  • Nope it doesn't work. I tried replacing myScript with gedit and option with encoding and it doesn't work. However if I try removing option altogether, then it works. – posixKing Feb 14 '17 at 10:06
  • --option& looks like typo, is it really legal? – user1700494 Feb 14 '17 at 10:07
  • Well no idea, maybe it is legal, but I am not sure if we can use exit after that. Maybe we need a semicolon or && before exit. – posixKing Feb 14 '17 at 10:12
  • gedit puts itself in background. – Satō Katsura Feb 14 '17 at 10:19
1

This works perfectly for me:

alias myAlias='nohup myScript --option& exit'

Why not use exit in myScript if you want to run the script with option "option" in background and then exit from bash, because once the program is run in the background , its terminal independent right ?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.