You are not logged in.
Pages: 1
say for instance id like to add an alias to my bashrc
say like
alias removeallpa='su -c pacman -Rs'
so that i can use pacman to remove a file
what is the correct syntax for the command to get it working properly
i know on the command line when i run
su -c 'pacman -Rs firefox'
it works perfectly it prompts me for the password like i want
i just prefer not to use sudo any guidance how to get this to work i would appreciate thanks
Last edited by okplayer02 (2008-12-06 20:42:47)
Say what is good or keep silent --Prophet Muhammad (SAW)
Offline
try
alias supac="su -c 'pacman -Qi firefox'"
Last edited by u_no_hu (2008-12-06 14:36:49)
Offline
ah yes it did work perfectly the syntax now how can i go about typing the particular command like
supac firefox
obviously i will be using other programs other than firefox
it seems like i will have to use sudo to get around this problem but just looking for another solution
Say what is good or keep silent --Prophet Muhammad (SAW)
Offline
You could use a function.
function supac
{
su -c 'pacman -Qi $@'
}
I think that should work for you.
Offline
alias supac="su -c 'pacman -Qi "
you will have to fill in the other quote while running the command ;-) supac firefox'
and i dont know what will happen to other aliases if they are coming after this ... unchartered territory use at your own risk;-)
Offline
ah i see i will give a test try
so for my alias it would be like so
alias supac="su -c 'pacman -Qi'"
and as u explained with the next function it will define the alias if im correct?
function supac
{
su -c 'pacman -Qi $@'
}
i dont mind cause im getting a lesson now i wasnt planning but i appreciate the help guys i take all disclaimers of course.
Say what is good or keep silent --Prophet Muhammad (SAW)
Offline
dont close the single quote ... i feel terribly ugly recommending this......
Offline
well i made a few adjustments to that function
function supac
{
su -c 'pacman -Rs $@'
}
when i run
supac
it prompts for password then proceeds to list every package but if i do
supac firefox
it prompts for password then give the following message:
error: no targets specified (use -h for help)
like i say i seen this with sudo but surely it must be the same for su -c
must be an way to get it working though i been looking at other examples but nothing so far
Say what is good or keep silent --Prophet Muhammad (SAW)
Offline
I think the '$@' doesn't get expanded because it's enclosed in single quotes.
This seems to work:
function supac {
eval su -c \'pacman -Rs "$@"\'
}
Stand back, intruder, or i'll blast you out of space! I am Klixon and I don't want any dealings with you human lifeforms. I'm a cyborg!
Offline
well yes that did thanks it is solved
thanks for that last tip
Say what is good or keep silent --Prophet Muhammad (SAW)
Offline
Ah crap, foiled by single quotes.
On the other hand, I don't think you really need to quote $@ in this instance, so this should probably work too:
function supac {
su -c "pacman -Rs $@"
}
Offline
sudo?
Offline
And if you want to error with no args:
function omgwtf() {
if [ $# -eq 0 ]; then
echo "usage: omgwtf <packages to remove>"
else
su -c "pacman -Rs $@"
fi
}
Offline
Pages: 1