Quote function names to improve curl safety (can't accidentally call a command that's the first half of a function's name for example)

This commit is contained in:
Danielle McLean 2016-10-22 21:54:25 +11:00
parent e098adf56f
commit 0eed4b0a0e
No known key found for this signature in database
GPG key ID: CC91589719027E94

View file

@ -1,6 +1,6 @@
#!/usr/bin/env zsh #!/usr/bin/env zsh
bootstrap() { 'bootstrap'() {
echo 'Bootstrapping your dotfiles...' >&2 echo 'Bootstrapping your dotfiles...' >&2
mkdir -p $DOTFILES mkdir -p $DOTFILES
touch $DOTFILES/.stow touch $DOTFILES/.stow
@ -14,14 +14,14 @@ bootstrap() {
link link
} }
clone() { 'clone'() {
echo "Requested packages: $argv" >&2 echo "Requested packages: $argv" >&2
for package in $argv; do for package in $argv; do
clone-one $package || return $? clone-one $package || return $?
done done
} }
clone-one() { 'clone-one'() {
local url=$1 local url=$1
local package=${${url##*/}%.git} local package=${${url##*/}%.git}
# Simple package names are fetched from my GitHub repos. # Simple package names are fetched from my GitHub repos.
@ -36,7 +36,7 @@ clone-one() {
git clone $url $DOTFILES/$package git clone $url $DOTFILES/$package
} }
link() { 'link'() {
local -a packages local -a packages
packages=($argv) packages=($argv)
if (( $#packages == 0 )); then if (( $#packages == 0 )); then
@ -55,7 +55,7 @@ link() {
$STOW -d $DOTFILES -t ~ $packages $STOW -d $DOTFILES -t ~ $packages
} }
process-stow-no-folding() { 'process-stow-no-folding'() {
zmodload zsh/mapfile zmodload zsh/mapfile
for file in ${(f)mapfile[$1]}; do for file in ${(f)mapfile[$1]}; do
file=~/$file file=~/$file
@ -65,7 +65,7 @@ process-stow-no-folding() {
done done
} }
fetch() { 'fetch'() {
local -a packages local -a packages
packages=($argv) packages=($argv)
(( $#packages == 0 )) && packages=( $DOTFILES/*(N:t) ) (( $#packages == 0 )) && packages=( $DOTFILES/*(N:t) )
@ -75,7 +75,7 @@ fetch() {
done done
} }
status() { 'status'() {
local -a packages local -a packages
packages=($argv) packages=($argv)
(( $#packages == 0 )) && packages=( $DOTFILES/*(N:t) ) (( $#packages == 0 )) && packages=( $DOTFILES/*(N:t) )