config

OpenBSD system configuration
git clone git://jacobedwards.org/config
Log | Files | Refs | README

commit e1b84cbaac75940734858f23527ef9c35d2d71ec
parent 26a4c23fbd6f1711f4833d35362f8b48681b2ee6
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date:   Mon, 15 Feb 2021 00:53:51 -0800

Fix how shell functions pass arguments

Use `@' when trying to pass arguments through functions, from
OpenBSD's ksh(1) manual:

        [...] $@ can be used to access arguments, verbatim, without
        losing NULL arguments or splitting arguments with spaces.

Diffstat:
Mmodules/shell/.config/shell/aliases | 24++++++++++++------------
Mmodules/shell/.config/shell/etc | 10+++++-----
Mmodules/shell/.config/shell/fs | 8++++----
Mmodules/shell/.config/shell/gopher | 4++--
Mmodules/shell/.config/shell/hist | 4++--
Mmodules/shell/.config/shell/main | 2+-
Mmodules/shell/.config/shell/mpc | 20++++++++++----------
Mmodules/shell/.config/shell/openbsd | 16++++++++--------
Mmodules/shell/.config/shell/sys | 4++--
Mmodules/shell/.config/shell/xorg | 8++++----
10 files changed, 50 insertions(+), 50 deletions(-)

diff --git a/modules/shell/.config/shell/aliases b/modules/shell/.config/shell/aliases @@ -1,15 +1,15 @@ # simple shell functions -ap() { apropos $* ;} -date() { command date ${*:-'+%F %T %z'} ;} -grep() { egrep $* ;} -man() { command man $* ;} -mtime() { stat -t '%F %T' -f%Sm%t%N $* ;} -pkill() { command pkill -x $* ;} -sed() { command sed -E $* ;} +ap() { apropos "$@" ;} +date() { command date "${@:-+%F %T %z}" ;} +grep() { egrep "$@" ;} +man() { command man "$@" ;} +mtime() { stat -t '%F %T' -f%Sm%t%N "$@" ;} +pkill() { command pkill -x "$@" ;} +sed() { command sed -E "$@" ;} -f() { $EDITOR $* ;} -g() { git $* ;} -l() { $PAGER $* ;} -t() { tmux $* ;} -d() { doas $* ;} +f() { $EDITOR "$@" ;} +g() { git "$@" ;} +l() { $PAGER "$@" ;} +t() { tmux "$@" ;} +d() { doas "$@" ;} diff --git a/modules/shell/.config/shell/etc b/modules/shell/.config/shell/etc @@ -1,12 +1,12 @@ # shell functions -fed() (test $# -gt 1 && cd ${FEED_DIR:?unset} && feed $*) -hfmt() lynx -dump ${*:-'-stdin'} -loop() while eval $*; do done -wloop() while { read && eval $* ;}; do done +fed() (test $# -gt 1 && cd ${FEED_DIR:?unset} && feed "$@") +hfmt() lynx -dump "${@:--stdin}" +loop() while eval "$@"; do done +wloop() while { read && eval "$@" ;}; do done tp() { - case $* in + case "$@" in y) export ALL_PROXY="socks://localhost:9050" # curl export HTTP_PROXY=$ALL_PROXY;; # vimb n) unset ALL_PROXY; unset HTTP_PROXY;; diff --git a/modules/shell/.config/shell/fs b/modules/shell/.config/shell/fs @@ -1,10 +1,10 @@ # filesystem shell functions -ls() { command ls -1 $* ;} -lsc() { ls $* | rs ;} -sfind() { find . -maxdepth 1 $* ;} +ls() { command ls -1 "$@" ;} +lsc() { ls "$@" | rs ;} +sfind() { find . -maxdepth 1 "$@" ;} fp() { - local bin=`which $* 2>/dev/null` + local bin=`which "$@" 2>/dev/null` f ${bin:?No path specified} } diff --git a/modules/shell/.config/shell/gopher b/modules/shell/.config/shell/gopher @@ -1,4 +1,4 @@ # gopher shell functions -veronica() (local IFS='?' && gawk "/v2/vs/?${*:?No query}" floodgap.com) -vs() { veronica $* ;} +veronica() (local IFS='?' && gawk "/v2/vs/?${@:?No query}" floodgap.com) +vs() { veronica "$@" ;} diff --git a/modules/shell/.config/shell/hist b/modules/shell/.config/shell/hist @@ -3,5 +3,5 @@ unalias r 2>/dev/null k() { fc -s ;} -r() { fc -s "$*" ;} -hs() { fc -nl 0 | egrep $* ;} +r() { fc -s ""$@"" ;} +hs() { fc -nl 0 | egrep "$@" ;} diff --git a/modules/shell/.config/shell/main b/modules/shell/.config/shell/main @@ -1,7 +1,7 @@ # shell module hub include() { - for module in $* + for module in "$@" do local include="${SHELL_MODULE_DIR:?unset}/$module" test -f "$include" || { diff --git a/modules/shell/.config/shell/mpc b/modules/shell/.config/shell/mpc @@ -1,12 +1,12 @@ # mpc shell functions -m() { mpc $* ;} -mP() { m searchplay any $* ;} -ma() { m add $* ;} -mi() { m play $* ;} -mj() { m next $* ;} -ml() { m playlist $* ;} -mo() { m prev $* ;} -ms() { m search any $* ;} -mt() { m toggle $* ;} -mf() { m listall | egrep $* ;} +m() { mpc "$@" ;} +mP() { m searchplay any "$@" ;} +ma() { m add "$@" ;} +mi() { m play "$@" ;} +mj() { m next "$@" ;} +ml() { m playlist "$@" ;} +mo() { m prev "$@" ;} +ms() { m search any "$@" ;} +mt() { m toggle "$@" ;} +mf() { m listall | egrep "$@" ;} diff --git a/modules/shell/.config/shell/openbsd b/modules/shell/.config/shell/openbsd @@ -1,12 +1,12 @@ # OpenBSD shell functions -ncpu() { sysctl -n hw.ncpufound $* ;} -load() { sysctl -n vm.loadavg $* ;} +ncpu() { sysctl -n hw.ncpufound "$@" ;} +load() { sysctl -n vm.loadavg "$@" ;} # package management -pa() { doas pkg_add -xV $* ;} -pd() { doas pkg_delete -xV $* ;} -pi() { pkg_info $* ;} -pu() { doas pkg_add -u $* ;} -pq() { egrep $* /usr/local/share/ports-INDEX | cut -d'|' -f1,4 | tr '|' '\t' ;} -pQ() { pkg_locate $* ;} +pa() { doas pkg_add -xV "$@" ;} +pd() { doas pkg_delete -xV "$@" ;} +pi() { pkg_info "$@" ;} +pu() { doas pkg_add -u "$@" ;} +pq() { egrep "$@" /usr/local/share/ports-INDEX | cut -d'|' -f1,4 | tr '|' '\t' ;} +pQ() { pkg_locate "$@" ;} diff --git a/modules/shell/.config/shell/sys b/modules/shell/.config/shell/sys @@ -1,4 +1,4 @@ # system management shell functions -doas() { command doas -- $* ;} -dsu() { doas su $* ;} +doas() { command doas -- "$@" ;} +dsu() { doas su "$@" ;} diff --git a/modules/shell/.config/shell/xorg b/modules/shell/.config/shell/xorg @@ -1,6 +1,6 @@ # xorg shell functions -grab() { xclip -selection clipboard $* ;} -dump() { grab -out $* ;} -pdf() { zathura $* ;} -x() { startx $* ;} +grab() { xclip -selection clipboard "$@" ;} +dump() { grab -out "$@" ;} +pdf() { zathura "$@" ;} +x() { startx "$@" ;}