[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Pan-users] Re: Shortcuts gone?
From: |
Christophe Lambin |
Subject: |
Re: [Pan-users] Re: Shortcuts gone? |
Date: |
Fri, 18 Aug 2006 01:35:51 +0200 |
User-agent: |
Mutt/1.4.2.1i |
On Fri, 18 Aug, 2006 at 00:18 +0200, Brad Sims wrote:
> Yeah I know about as elegant as a Russian sledgehammer; but it works
> and was the first script I ever wrote.
Well, since you posted it, I can't resist reviewing it. :)
> b=`ls ~/.sigs | wc -w`
> RANGE=$b
> number=$RANDOM
> let "number %= $RANGE"
So, your sig files are named sig001, sig002, ... sig<nnn>, right ?
Since you're modding the count, number is now 0 ... n-1.
You would reuse b (i.e. let number %= $b). You also don't need the
quotes (I think; any reason why you added them?).
> if [ $number = "0" ]
> then
> number=1
> else
> number=$number
> fi
You actually need to do:
let number+=1
(or you'll never use the last one).
> # this makes sure that it reads the right file,
> # ie: sig001 not sig1.
The whole section doing this be done as USEME=`printf "%03d" $number. :)
Personally, I'd write:
# index all the files
let count=0
for d in `ls ~/.sigs`; do
file[$count]="$d"
let count+=1
done
# file is now an array of filenames, count the number of files
# pick a file
index=$(($RANDOM%$count))
# Output the file
cat ${file[$index]}
This way, your code doesn't make any assumptions on the filenames within
your .sigs directory.
> # This puts the random sig in a file named .slrnsig in the News directory
> # and moves the old sig into a file named .slrnsig.old in case you want to
> # use it instead.
If you'd only need something for Pan, you could just let the script cat
the file, and let Pan call the script.
Regards,
Christophe
pgpW_IywVmRMW.pgp
Description: PGP signature
- [Pan-users] Re: Shortcuts gone?, (continued)
- [Pan-users] Re: Shortcuts gone?, Duncan, 2006/08/16
- Re: [Pan-users] Re: Shortcuts gone?, Bruce Bowler, 2006/08/16
- [Pan-users] Re: Shortcuts gone?, Duncan, 2006/08/17
- [Pan-users] Re: Shortcuts gone?, Mick Semb Wever, 2006/08/17
- [Pan-users] Re: Shortcuts gone?, Mick Semb Wever, 2006/08/17
- Re: [Pan-users] Re: Shortcuts gone?, Brad Sims, 2006/08/17
- Re: [Pan-users] Re: Shortcuts gone?,
Christophe Lambin <=