Do some crazy stuff with OPTIND to unbreak getopts interoperation.

This commit is contained in:
Ivan Malison 2014-08-26 12:47:43 -07:00
parent ca17d69e4a
commit d731e62b04
6 changed files with 252 additions and 250 deletions

View File

@ -119,7 +119,7 @@ function do_the_brew() {
esac
done
echo "Installing the following packages:"
for package_name in "${install_items[@]}"; do echo $package_name; done;
for package_name in "${install_items[@]}"; do printf '\t%s\n' $package_name; done;
brew update
brew_install_items $install_items
brew cleanup

View File

@ -228,10 +228,10 @@ function ss() {
}
function git_config_string() {
git config -f $1 --list | xargs -I kv sh -c "echo \\\"kv\\\"" | xargs | tr '\n' ' '
git config -f $1 --list | xargs -I kv printf '-c \"%s\" ' kv
}
function brew_for_multiple_user() {
function brew_for_multiple_users() {
sudo chgrp -R admin /usr/local
sudo chmod -R g+w /usr/local
sudo chgrp -R admin /Library/Caches/Homebrew

View File

@ -1,4 +1,5 @@
function install_python_packages() {
easy_install pip
ESSENTIAL=(ipdb ipython virtualenv)
FOR_EDITOR=(jedi pyflakes)
USEFUL=(

View File

@ -1,5 +1,3 @@
function vimstall() {
# This sucks, but BundleInstall fails otherwise.
sudo chmod -R 775 $(readlink -f ~/.vim)
vim +BundleInstall! +q +q
}

View File

@ -1,5 +1,4 @@
#!/usr/bin/env bash
function osx_config() {
# Ask for the administrator password upfront
sudo -v
@ -325,3 +324,4 @@ defaults write org.m0k.transmission DeleteOriginalTorrent -bool true
defaults write org.m0k.transmission WarningDonate -bool false
# Hide the legal disclaimer
defaults write org.m0k.transmission WarningLegal -bool false
}

View File

@ -4,6 +4,7 @@ source dotfiles/lib/shellrc/functions.sh
source dotfiles/lib/shellrc/brew.sh
source dotfiles/lib/shellrc/python.sh
source dotfiles/lib/shellrc/vim.sh
source resources/osx.sh
DOTFILES_DIRECTORY="$(dotfiles_abspath)/dotfiles"
@ -74,6 +75,7 @@ function setup() {
fi
while getopts "acosbpev" OPTCHAR;
do
local real_opt_ind=$OPTIND
case $OPTCHAR in
a)
source resources/apt-get.sh
@ -90,7 +92,7 @@ function setup() {
;;
o)
sudo -v
source resources/osx.sh
osx_config
;;
s)
symlink_dotfiles_prompt
@ -104,10 +106,11 @@ function setup() {
install_python_packages $REPLY
;;
e)
case uname in
case $(uname) in
Darwin)
get_command_line_tools
get_brew && do_the_brew -au
osx_config
;;
Linux)
apt-get
@ -115,7 +118,6 @@ function setup() {
esac
install_python_packages -a
symlink_dotfiles
source resources/osx.sh
vimstall
;;
v)
@ -126,6 +128,7 @@ function setup() {
return
;;
esac
OPTIND=$real_opt_ind
done
}