You are not logged in.
Hello
I created this script:
#!/bin/zsh
#filename: /usr/bin/pacman2
#usa pacman2 instead of pacman
if [[ $1 = -Ss ]]; then
if [[ `pacman -Ss $2` = "" ]]
then
yaourt -Ss $2
else
pacman-color -Ss $2
fi
else
pacman-color $*
fi
First it searches in pacman, and if nothing found then it searches in yaourt.
The question is how can I keep from running twice 'pacman -Ss' (lines 3 and 7). I tried:
#!/bin/zsh
#filename: /usr/bin/pacman2
if [[ $1 = -Ss ]]; then
/usr/bin/pacman-color -Ss $2 > /dev/stdout > /tmp/file
if [[ `cat /tmp/file` = "" ]]
# if [[ `pacman -Ss $2` = "" ]]
then
yaourt -Ss $2
# else
# pacman-color -Ss $2
fi
else
pacman-color $*
fi
However, output isn't colored. Why?
Searching in yaourt only is very slow (yaourt is much slower than pacman).
Thanks
Offline
Easy, pacman seems to return 1 if it doesn't find anything. And i fixed your argument handling, calling pacman-color -Ss $2 would only work for some searches.
#!/bin/zsh
#filename: /usr/bin/pacman2
#usa pacman2 instead of pacman
if [[ $1 = -Ss ]]; then
shift
pacman-color -Ss $@
if [ $? -eq 1 ]
then
yaourt -Ss $@
fi
else
pacman-color $*
fi
Regards,
raf
Last edited by raf_kig (2009-08-10 21:19:39)
Offline
pacman -Ss returns a non-zero exit status on failure, so you can run it in any case, and use || to decide whether yaourt needs to be run:
if [[ "$1" == "-Ss" ]]; then
pacman-color -Ss $2 || yaourt -Ss $2
else
pacman-color $*
fi
No idea why your output isn't colored, though.
Offline
I have to admit that I don't understand what's the point of this script. Yaourt already searches from both std repos and AUR, why you need to choose between use pacman or use yaourt with this script?
Offline
Berseker: yaourt is slow. Try to search "kde" with pacman and then with yaourt. You'll see the difference.
raf_kig, hbekel: thanks for help
Offline
mmm you're right. I didn't feel the difference because for searching i use the awesome tool "tupac", much more faster than both yaourt & pacman. I have set tupac as alias "yaourtss" in my bashrc and when I've to search something, I use that. Maybe you can try too
Offline
well, I tried tupac but it doesn't fit to me... pacman & yaourt is problably the best combination
Offline
you could take a lot @ slurpy's code . It's made in python or aurget that's made in bash
Offline