Christoph Gysin schreef:
> David Morgan wrote:
> 
>>afaik you can only do it with su -c "echo foo >> bar", which stops bash
>>from doing anything with the >> or the whitespace to begin with, but
>>then passes everything inside the double quotes to another shell, which
>>gets started by su -c
>>
>>It's kind of annoying, I know, but I don't think there's a way round it
>>with sudo.
> 
> 
> Yes it is possible. But you need the shell (which handles the redirect)
> to run as root.

Ah-HAH! (at least I figured that much out, thanks for confirming)

> 
> $ sudo echo package ~x86 >> /etc/portage/package.keywords
> 
> will run the redirection as user, where:
> 
> $ sudo bash -c "echo package ~x86 >> /etc/portage/package.keywords"
> 
> will run the redirection as root.
> 
> For stuff like this, I'd recommend you to write simple shell functions:
> 
> addkeyword(){
>   sudo bash -c "echo $* >> /etc/portage/package.keywords"
> }
> 
> Write them in your .bashrc and their avaible when you need it.
> 
> Use it like this:
> 
> $ addkeyword package ~x86
> 
> Christoph

Thank you, Christoph!!!!

You have not only saved my sanity, but you've given me a solution to two
problems you didn't even know I had (it was the next question)! i.e.,
how to essentially export self-created variables or something similar
(you don't know how many times I've put a comma between package and
keywords/use/unmask, and I really needed some way to not have to be
typing it all the time until I get more time in with GTypist); and also
how to easily use some of the aliases I've got in root's .bashrc (or at
least their functionality). Now, with some minor adjustments of this
template, not only can I add keywords (or useflags or mask and unmask)
easily, I can also open the package.* file in nano and edit it easily if
I screw up, or want to check something.

Last question on this subject-- is this all just bash scripting (so I
can learn about it if I sit and study the abs-guide) or is there
someplace else I should check out if I want to learn how to write this
stuff myself?

Thanks again,
Holly



-- 
gentoo-user@gentoo.org mailing list

Reply via email to