summaryrefslogtreecommitdiff
path: root/etc/functions
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2010-04-02 11:32:38 +0200
committerDaniel Friesel <derf@derf.homelinux.org>2010-04-02 11:32:38 +0200
commitf0f3c02a3ccde07d3dc79577c7eca41ea3e8e86f (patch)
treed0aaab1de872a30a94555d2da3b501e13e18c217 /etc/functions
parent81ac4a06bff278f07620804b7d4120342b1f6522 (diff)
Replace $var by ${var}
Diffstat (limited to 'etc/functions')
-rw-r--r--etc/functions/colortable2
-rw-r--r--etc/functions/dpkg-hold2
-rw-r--r--etc/functions/dpkg-unhold2
-rw-r--r--etc/functions/extract36
-rw-r--r--etc/functions/finfo10
-rw-r--r--etc/functions/gtd-all8
-rw-r--r--etc/functions/gtd-move14
-rw-r--r--etc/functions/help34
-rw-r--r--etc/functions/mkcd10
-rw-r--r--etc/functions/need-comp4
-rw-r--r--etc/functions/newsbeuter4
-rw-r--r--etc/functions/off22
-rw-r--r--etc/functions/plonkhost2
-rw-r--r--etc/functions/put36
-rw-r--r--etc/functions/reload6
-rw-r--r--etc/functions/rtab34
-rw-r--r--etc/functions/whichf4
17 files changed, 115 insertions, 115 deletions
diff --git a/etc/functions/colortable b/etc/functions/colortable
index fadd7a7..ab46eb4 100644
--- a/etc/functions/colortable
+++ b/etc/functions/colortable
@@ -2,7 +2,7 @@
## print a table with all 256 color codes
for i in {0..255}; {
- printf " %s%-3s" $'\e[38;5;'${i}m $i
+ printf " %s%-3s" $'\e[38;5;'${i}m ${i}
(( (i+1) % (COLUMNS/4) < 1 )) && echo
}
echo
diff --git a/etc/functions/dpkg-hold b/etc/functions/dpkg-hold
index b905114..6e98e87 100644
--- a/etc/functions/dpkg-hold
+++ b/etc/functions/dpkg-hold
@@ -1 +1 @@
-echo $1 hold | sudo dpkg --set-selections
+echo ${1} hold | sudo dpkg --set-selections
diff --git a/etc/functions/dpkg-unhold b/etc/functions/dpkg-unhold
index 7bc785b..791c8aa 100644
--- a/etc/functions/dpkg-unhold
+++ b/etc/functions/dpkg-unhold
@@ -1 +1 @@
-echo $1 install | sudo dpkg --set-selections
+echo ${1} install | sudo dpkg --set-selections
diff --git a/etc/functions/extract b/etc/functions/extract
index 9312678..2156dab 100644
--- a/etc/functions/extract
+++ b/etc/functions/extract
@@ -2,25 +2,25 @@
## Extract archives
## Usage: extr <file>
-if [[ -f $1 ]] {
- case $1 in
- *.(tar.bz2|tbz2)) tar xvjf $* ;;
- *.(tar.gz|tgz)) tar xvzf $* ;;
- *.tar.lzma) unlzma $1 | tar xv ;;
- *.ace) unace e $1 ;;
- *.rar) unrar x $1 ;;
- *.deb) ar -x $1 ;;
- *.bz2) bunzip2 $1 ;;
- *.lzh) lha x $1 ;;
- *.gz) gunzip $1 ;;
- *.tar) tar xvf $* ;;
- *.zip) unzip $1 ;;
- *.Z) uncompress $1 ;;
- *.cpio) cpio --no-absolute-filenames -idv < $1 ;;
- *.lzma) unlzma $1 ;;
- *) echo "Unknown archive type: $1"; return 2 ;;
+if [[ -f ${1} ]] {
+ case ${1} in
+ *.(tar.bz2|tbz2)) tar xvjf ${*} ;;
+ *.(tar.gz|tgz)) tar xvzf ${*} ;;
+ *.tar.lzma) unlzma ${1} | tar xv ;;
+ *.ace) unace e ${1} ;;
+ *.rar) unrar x ${1} ;;
+ *.deb) ar -x ${1} ;;
+ *.bz2) bunzip2 ${1} ;;
+ *.lzh) lha x ${1} ;;
+ *.gz) gunzip ${1} ;;
+ *.tar) tar xvf ${*} ;;
+ *.zip) unzip ${1} ;;
+ *.Z) uncompress ${1} ;;
+ *.cpio) cpio --no-absolute-filenames -idv < ${1} ;;
+ *.lzma) unlzma ${1} ;;
+ *) echo "Unknown archive type: ${1}"; return 2 ;;
esac
} else {
- echo "No such file: $1"
+ echo "No such file: ${1}"
return 1
}
diff --git a/etc/functions/finfo b/etc/functions/finfo
index 62a5fe9..f0c9429 100644
--- a/etc/functions/finfo
+++ b/etc/functions/finfo
@@ -4,11 +4,11 @@
## Usage: finfo <function name>
typeset line
-whichf $1 &> /dev/null || return 1
+whichf ${1} &> /dev/null || return 1
while read line; do
- [[ $line == \#* ]] || break
- [[ $line == *vim:ft=* ]] && continue
- [[ $line == \#(autoload|compdef)* ]] && continue
+ [[ ${line} == \#* ]] || break
+ [[ ${line} == *vim:ft=* ]] && continue
+ [[ ${line} == \#(autoload|compdef)* ]] && continue
echo ${line#(\#|)\# }
-done < $(whichf $1)
+done < $(whichf ${1})
diff --git a/etc/functions/gtd-all b/etc/functions/gtd-all
index ddbfdba..3cbdde5 100644
--- a/etc/functions/gtd-all
+++ b/etc/functions/gtd-all
@@ -5,8 +5,8 @@ typeset prefix=~/var/gtd
typeset database
typeset -i force
-while [[ $1 == -* ]] {
- case $1 in
+while [[ ${1} == -* ]] {
+ case ${1} in
-|--) shift; break ;;
--force) force=1 ;;
esac
@@ -26,7 +26,7 @@ function gtd_grep {
return 0
}
-for database in $prefix/*(.N); {
+for database in ${prefix}/*(.N); {
echo "\n${database:t}"
- todo --database $database $* | gtd_grep
+ todo --database ${database} ${*} | gtd_grep
}
diff --git a/etc/functions/gtd-move b/etc/functions/gtd-move
index fa03800..eed7861 100644
--- a/etc/functions/gtd-move
+++ b/etc/functions/gtd-move
@@ -9,14 +9,14 @@ if [[ ${#*} != 3 ]] {
return
}
-typeset prefix="$HOME/var/gtd"
+typeset prefix="${HOME}/var/gtd"
typeset format='display=%T\n%p'
-typeset from=$1
-typeset itemno=$2
-typeset to=$3
+typeset from=${1}
+typeset itemno=${2}
+typeset to=${3}
typeset IFS=$'\n'
typeset -a item
-item=($(todo --database $prefix/$from --format $format $itemno))
-todo --database $prefix/$to --priority $item[2] --add $item[1]
-todo --database $prefix/$from --remove $itemno
+item=($(todo --database ${prefix}/${from} --format ${format} ${itemno}))
+todo --database ${prefix}/${to} --priority ${item[2]} --add ${item[1]}
+todo --database ${prefix}/${from} --remove ${itemno}
diff --git a/etc/functions/help b/etc/functions/help
index db3eca1..bad1b75 100644
--- a/etc/functions/help
+++ b/etc/functions/help
@@ -6,47 +6,47 @@ typeset method topic
typeset -i found check_only all
methods=(man zshfunction zshbuiltin apt)
-while [[ $1 == -* ]] {
- case $1 in
+while [[ ${1} == -* ]] {
+ case ${1} in
-a|--all) all=1 ;;
-c|--check-only) check_only=1 ;;
- -t|--topic) topic=$2; shift ;;
+ -t|--topic) topic=${2}; shift ;;
-|--) shift; break ;;
- *) echo "unknown option: $1" ;;
+ *) echo "unknown option: ${1}" ;;
esac
shift
}
-function help_check_man { man -w $1 &> /dev/null }
-function help_check_zshfunction { whichf $1 &> /dev/null }
+function help_check_man { man -w ${1} &> /dev/null }
+function help_check_zshfunction { whichf ${1} &> /dev/null }
function help_check_zshbuiltin { (( ${+builtins[$1]} )) }
function help_check_apt {
- [[ $commands[$1] != ${HOME}* ]] && [[ -n $commands[$1] ]] && [[ -n $commands[apt-file ]]
+ [[ ${commands[$1]} != ${HOME}* ]] && [[ -n ${commands[$1]} ]] && [[ -n ${commands[apt-file]} ]]
}
-function help_show_man { man $1 }
-function help_show_zshfunction { finfo $1 }
-function help_show_zshbuiltin { man zshbuiltins | less -p " $1" }
+function help_show_man { man ${1} }
+function help_show_zshfunction { finfo ${1} }
+function help_show_zshbuiltin { man zshbuiltins | less -p " ${1}" }
function help_show_apt {
- apt-cache show ${(s/:/)$(apt-file search -F $commands[$1])[1]}
+ apt-cache show ${(s/:/)$(apt-file search -F ${commands[$1]})[1]}
}
-if [[ -z $1 ]] {
+if [[ -z ${1} ]] {
echo "Usage: help <command>" > /dev/stderr
return 1
}
-for method in $methods; {
- if [[ -n $topic && $method != $topic ]] {
+for method in ${methods}; {
+ if [[ -n ${topic} && ${method} != ${topic} ]] {
continue
}
- if help_check_$method $1; then
+ if help_check_${method} ${1}; then
((found++))
if ((check_only)) {
- echo $method
+ echo ${method}
continue
}
- help_show_$method $1
+ help_show_${method} ${1}
((all)) || break
fi
}
diff --git a/etc/functions/mkcd b/etc/functions/mkcd
index bd6158d..e91719a 100644
--- a/etc/functions/mkcd
+++ b/etc/functions/mkcd
@@ -1,13 +1,13 @@
## vim:ft=zsh
## create a directory, then change into it
typeset -i ls=0
-typeset dir=$1
+typeset dir=${1}
-if [[ -z $dir ]] {
+if [[ -z ${dir} ]] {
echo "Usage: mkcd <directory name>" > /dev/stderr
return 1
}
-if [[ -d $dir ]] ls=1
-mkdir -p $dir
-cd $dir
+if [[ -d ${dir} ]] ls=1
+mkdir -p ${dir}
+cd ${dir}
if ((ls)) ls --color=auto
diff --git a/etc/functions/need-comp b/etc/functions/need-comp
index a38b561..9326157 100644
--- a/etc/functions/need-comp
+++ b/etc/functions/need-comp
@@ -1,9 +1,9 @@
## vim:ft=zsh
check_comp() {
- ((! $+_comps[$1])) && print $1
+ ((! ${+_comps[$1]})) && print ${1}
}
{
- for f ($^path/*(N:t)) check_comp $f
+ for f (${^path}/*(N:t)) check_comp ${f}
} | sort
diff --git a/etc/functions/newsbeuter b/etc/functions/newsbeuter
index 3756183..d010b82 100644
--- a/etc/functions/newsbeuter
+++ b/etc/functions/newsbeuter
@@ -2,11 +2,11 @@
## wrapper around newsbeuter to keep the feeds in sync
function __sync {
- if [[ $HOST != aneurysm ]] {
+ if [[ ${HOST} != aneurysm ]] {
unisync unison aneurysm .newsbeuter
}
}
__sync || return 1
-command newsbeuter $*
+command newsbeuter ${*}
__sync
diff --git a/etc/functions/off b/etc/functions/off
index 1edd2d8..adf666f 100644
--- a/etc/functions/off
+++ b/etc/functions/off
@@ -11,14 +11,14 @@ typeset -i force reboot simulate exit_ok=1
function execute {
if (( simulate )) {
- echo $*
+ echo ${*}
} else {
- $* || exit_ok=0
+ ${*} || exit_ok=0
}
}
-while [[ $1 == -* ]] {
- case $1 in
+while [[ ${1} == -* ]] {
+ case ${1} in
-n) simulate=1 ;;
-r) reboot=1 ;;
--force) force=1 ;;
@@ -33,13 +33,13 @@ while [[ $1 == -* ]] {
return 0
;;
-|--) shift; break ;;
- *) echo "Unrecognized option: $1" >&2 ; return 1 ;;
+ *) echo "Unrecognized option: ${1}" >&2 ; return 1 ;;
esac
shift
}
# Don't shut down a server too easily
-if [[ $force != 1 && $hosts[$HOST] == *:server:* ]] {
+if [[ ${force} != 1 && ${hosts[$HOST]} == *:server:* ]] {
print -P '%B%F{yellow}This seems to be a server... not shutting down%f%b'
echo "Use 'off --force' if you really mean it"
return 1
@@ -52,16 +52,16 @@ fi
execute uinit -o text stop-all
while read filesystem garbage; do
- if [[ $garbage == *[12] ]] && fgrep -q $filesystem /etc/mtab; then
- filesystems+=$filesystem
+ if [[ ${garbage} == *[12] ]] && fgrep -q ${filesystem} /etc/mtab; then
+ filesystems+=${filesystem}
fi
done < /etc/fstab
-for filesystem in $filesystems; {
- tune2fs=($(sudo tune2fs -l $filesystem | fgrep -i 'mount count' | grep -o '[0-9]*'))
+for filesystem in ${filesystems}; {
+ tune2fs=($(sudo tune2fs -l ${filesystem} | fgrep -i 'mount count' | grep -o '[0-9]*'))
if (( tune2fs[2] - tune2fs[1] < 5 )) {
exit_ok=0
- echo "notice: filesystem $filesystem due to check in $((tune2fs[2] - tune2fs[1])) mounts"
+ echo "notice: filesystem ${filesystem} due to check in $((tune2fs[2] - tune2fs[1])) mounts"
}
}
if (( reboot )) {
diff --git a/etc/functions/plonkhost b/etc/functions/plonkhost
index d3020ed..6f62541 100644
--- a/etc/functions/plonkhost
+++ b/etc/functions/plonkhost
@@ -1,4 +1,4 @@
## vim:ft=zsh
## "plonk" (as in ignore) a host via iptables
## Usage: plonkhost <host>
-sudo iptables -I INPUT -s "$1" -j DROP
+sudo iptables -I INPUT -s "${1}" -j DROP
diff --git a/etc/functions/put b/etc/functions/put
index 1876852..4fe8279 100644
--- a/etc/functions/put
+++ b/etc/functions/put
@@ -11,7 +11,7 @@ typeset target_dir server_prefix
typeset file remote_file illegal
typeset -i n_hosts n_ping n_curl
-if [[ -z $commands[curl] ]]; then
+if [[ -z ${commands[curl]} ]]; then
function curl {return 0}
print -P "%B%F{yellow}curl not present, won't be able to check upload success%f%b"
fi
@@ -38,8 +38,8 @@ function put_becquerel () {
hosts=(aneurysm_int aneurysm becquerel)
hosts_nossl=(becquerel)
-while [[ $1 == -* ]] {
- case $1 in
+while [[ ${1} == -* ]] {
+ case ${1} in
-|--) shift; break ;;
*)
(( $(eval echo '$#'hosts_${1#-}) )) && eval hosts=\(\$hosts_${1#-}\)
@@ -49,21 +49,21 @@ while [[ $1 == -* ]] {
}
-n_hosts=$#hosts
-if [[ -f $1 ]] {
- file=$1
- while (( $#hosts )) {
+n_hosts=${#hosts}
+if [[ -f ${1} ]] {
+ file=${1}
+ while (( ${#hosts} )) {
remote_file=${file:t}
- put_$hosts[1]
- ping -c 1 $hostname &> /dev/null || ping6 -c 1 $hostname &> /dev/null
+ put_${hosts[1]}
+ ping -c 1 ${hostname} &> /dev/null || ping6 -c 1 ${hostname} &> /dev/null
if (( ? == 0 )) {
- if [[ $remote_file == ${~illegal} ]] {
+ if [[ ${remote_file} == ${~illegal} ]] {
remote_file=${remote_file:r}
}
- scp $ssh_options $file $hostname:$target_dir/$remote_file
- ssh $ssh_options $hostname "chmod 644 $target_dir$remote_file"
- if $(curl -fI $server_prefix$remote_file &> /dev/null); then
- echo $server_prefix$remote_file
+ scp ${ssh_options} ${file} ${hostname}:${target_dir}/${remote_file}
+ ssh ${ssh_options} ${hostname} "chmod 644 ${target_dir}${remote_file}"
+ if $(curl -fI ${server_prefix}${remote_file} &> /dev/null); then
+ echo ${server_prefix}${remote_file}
return 0
else
(( n_curl++ ))
@@ -73,11 +73,11 @@ if [[ -f $1 ]] {
}
shift hosts
}
- echo "Tried uploading to $n_hosts hosts without success" >&2
- ((n_ping)) && echo " - $n_ping hosts are unreachable" >&2
- ((n_curl)) && echo " - $n_curl errors while uploading" >&2
+ echo "Tried uploading to ${n_hosts} hosts without success" >&2
+ ((n_ping)) && echo " - ${n_ping} hosts are unreachable" >&2
+ ((n_curl)) && echo " - ${n_curl} errors while uploading" >&2
return 1
} else {
- echo "$1: No such file"
+ echo "${1}: No such file"
return 1
}
diff --git a/etc/functions/reload b/etc/functions/reload
index afa634f..20439c2 100644
--- a/etc/functions/reload
+++ b/etc/functions/reload
@@ -7,8 +7,8 @@ if [[ ${#*} == 0 ]] {
rehash
} else {
local function
- for function in $@; {
- unfunction $function
- autoload $function
+ for function in ${@}; {
+ unfunction ${function}
+ autoload ${function}
}
}
diff --git a/etc/functions/rtab b/etc/functions/rtab
index 7444fef..4ba828a 100644
--- a/etc/functions/rtab
+++ b/etc/functions/rtab
@@ -27,8 +27,8 @@ zstyle -t ':prompt:rtab' last && lastfull=1
zstyle -t ':prompt:rtab' short && short=1
zstyle -t ':prompt:rtab' tilde && tilde=1
-while [[ $1 == -* ]]; do
- case $1 in
+while [[ ${1} == -* ]]; do
+ case ${1} in
-f|--fish)
lastfull=1
short=1
@@ -61,32 +61,32 @@ while [[ $1 == -* ]]; do
done
typeset -a tree expn
-typeset result part dir=${1-$PWD}
+typeset result part dir=${1-${PWD}}
typeset -i i
-[[ -d $dir ]] || return 0
+[[ -d ${dir} ]] || return 0
if (( named )) {
for part in ${(k)nameddirs}; {
- [[ $dir == ${nameddirs[$part]}(/*|) ]] && dir=${dir/${nameddirs[$part]}/\~$part}
+ [[ ${dir} == ${nameddirs[$part]}(/*|) ]] && dir=${dir/${nameddirs[$part]}/\~${part}}
}
}
-(( tilde )) && dir=${dir/#$HOME/\~}
+(( tilde )) && dir=${dir/#${HOME}/\~}
tree=(${(s:/:)dir})
(
unfunction chpwd 2> /dev/null
# Start either in the currrent named directory or in /
- if [[ $tree[1] == \~* ]] {
+ if [[ ${tree[1]} == \~* ]] {
cd ${~tree[1]}
- result=$tree[1]
+ result=${tree[1]}
shift tree
} else {
cd /
}
- for dir in $tree; {
- if (( lastfull && $#tree == 1 )) {
- result+="/$tree"
+ for dir in ${tree}; {
+ if (( lastfull && ${#tree} == 1 )) {
+ result+="/${tree}"
break
}
@@ -94,19 +94,19 @@ tree=(${(s:/:)dir})
expn=(a b)
part=''
i=0
- until [[ (( ${#expn} == 1 )) || $dir == $expn || $i -gt 99 ]] do
+ until [[ (( ${#expn} == 1 )) || ${dir} == ${expn} || ${i} -gt 99 ]] do
(( i++ ))
- part+=$dir[$i]
+ part+=${dir[$i]}
expn=($(echo ${part}*(-/)))
# Never show a single . as directory
- if [[ $i == 1 && $dir[$i] == . ]] {
+ if [[ ${i} == 1 && ${dir[$i]} == . ]] {
expn=(a b)
- } elif [[ $short == 1 ]] {
+ } elif [[ ${short} == 1 ]] {
break
}
done
- result+="/$part"
- cd $dir
+ result+="/${part}"
+ cd ${dir}
shift tree
}
echo ${result:-/}
diff --git a/etc/functions/whichf b/etc/functions/whichf
index 01026c4..03bcbb7 100644
--- a/etc/functions/whichf
+++ b/etc/functions/whichf
@@ -1,7 +1,7 @@
## vim:ft=zsh
## locate the file corresponding to a function
-if [[ -n $(echo ${^fpath}/$1(-.N)) ]] {
- echo ${^fpath}/$1(-.N)
+if [[ -n $(echo ${^fpath}/${1}(-.N)) ]] {
+ echo ${^fpath}/${1}(-.N)
} else {
return 1
}