3

I find add-apt-repository very userful and use it quite often. I was wondering why it doesn't provide an option to do the add + update + install package in one command. I was planning to make a script for this, but ask for your advice first. Did someone already make that? Something like sudo add-apt-repository ppa:address -install package that works like the 3 commands but in one line. Would it be useful?

2

1 Answer 1

4

Commands are best if they are modular. add-apt-repository is supposed to add a repository, that's it; it shouldn't update and install the package.

If you want a one-liner to do this, it would be best to do it using && operator as follows:

sudo add-apt-repository ppa:address && sudo apt-get update && sudo apt-get install <package>

Note that the package will be install only if the previous two commands execute successfully (return 0).

If you want that the commands be executed irrespective of the return status of the previous commands(may be useful when ignorable errors occur- a 404 for some other ppa you have added and no longer exists), you can do this:

sudo add-apt-repository ppa:address; sudo apt-get update; sudo apt-get install <package>

Note the ; in place of &&- it is used to delimit two successive commands on the same line.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .