You are not logged in.

#1 2009-08-10 20:12:27

cinan
Member
From: Slovakia
Registered: 2008-07-04
Posts: 251
Website

Need help with pacman & yaourt search script

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

#2 2009-08-10 21:16:16

raf_kig
Member
Registered: 2008-11-28
Posts: 143

Re: Need help with pacman & yaourt search script

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

#3 2009-08-10 21:24:49

hbekel
Member
Registered: 2008-10-04
Posts: 311

Re: Need help with pacman & yaourt search script

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

#4 2009-08-11 05:41:59

Berseker
Member
From: Near Lecco, Italy
Registered: 2008-04-24
Posts: 258

Re: Need help with pacman & yaourt search script

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

#5 2009-08-11 09:14:04

cinan
Member
From: Slovakia
Registered: 2008-07-04
Posts: 251
Website

Re: Need help with pacman & yaourt search script

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 smile

Offline

#6 2009-08-11 16:58:29

Berseker
Member
From: Near Lecco, Italy
Registered: 2008-04-24
Posts: 258

Re: Need help with pacman & yaourt search script

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 wink

Offline

#7 2009-08-11 17:38:55

cinan
Member
From: Slovakia
Registered: 2008-07-04
Posts: 251
Website

Re: Need help with pacman & yaourt search script

well, I tried tupac but it doesn't fit to me... pacman & yaourt is problably the best combination

Offline

#8 2009-08-12 07:00:21

jelly
Administrator
From: /dev/null
Registered: 2008-06-10
Posts: 714

Re: Need help with pacman & yaourt search script

you could take a lot @ slurpy's code . It's made in python or aurget that's made in bash

Offline

Board footer

Powered by FluxBB