[linux-l] bash listen funktionen
Ivan F. Villanueva B.
iv at artificialidea.com
Sa Mai 20 21:48:50 CEST 2006
Hallo,
wieder Wochenende, die Zeit zu experimentieren.
Ich habe gerade wmii-3 installiert. In Bash habe ich mir etwas gebastelt (dank
http://tldp.org/LDP/abs/html/index.html), um zu nächste oder vorherige "view" zu
schalten. Allerdings bin ich mir sicher, es geht viel kurzer, nur ich habe nicht
rausbekommen wie. z.B. ich frage mich:
Kann man Arrays als Parameter für Funktionen benutzen ?
Wie bekomme ich das letzte Element eines Arrays? Kann man Zeilen als
Elemente eines Arrays zuweisen (array=`ls` ; array[1]) ?
Das Gebasteltes (smart question ;-):
#!/bin/sh
adjacent() {
active_tag=`cat /mnt/wmii/view/name`
found=""
for i in $list ; do
if [ "$found" == "true" ]; then
echo -n view "$i" >> /mnt/wmii/ctl
return
fi
if [ "$i" == "$active_tag" ]; then
found="true"
fi
done
# Nur um das erste Element rauszubekommen. Geht es anders ?
for i in $list ; do
echo -n view "$i" >> /mnt/wmii/ctl
return
done
}
next() {
list=`cat /mnt/wmii/tags`
adjacent
}
prev() {
list=`cat /mnt/wmii/tags | tac`
adjacent
}
Schönes Wochenende noch,
--
Ivan F. Villanueva B.
A.I. library: http://www.artificialidea.com
<<< The European Patent Litigation Agreement (EPLA) >>>
<<< will bring Software patents by the backdoor >>>
<<< http://www.no-lobbyists-as-such.com/florian-mueller-blog/epla/ >>>
<<< http://wiki.ffii.de/EplaEn >>>
Mehr Informationen über die Mailingliste linux-l