Permalink
Browse files

Calls to chdir(2) should be error checked

* Bad things can happen if you don't sanity check cd
  • Loading branch information...
1 parent df278fa commit 296fd390df4cb9ee382cf6786c7cf65963304222 @bahamas10 committed May 25, 2012
Showing with 16 additions and 11 deletions.
  1. +16 −11 bin/mad
View
27 bin/mad
@@ -118,14 +118,16 @@ install_all_remote() {
local path=${0%/*}/../share/mad
echo
echo " ... cloning repo"
- cd /tmp && rm -fr mad-pages
- git clone --depth 1 $REMOTE mad-pages
- cd mad-pages
- for page in *.md; do
- echo " ... installing $page"
- cp -f $page $path/$page
- done
- echo " ... complete"
+ cd /tmp && rm -fr mad-pages || exit 2
+ if git clone --depth 1 $REMOTE mad-pages && cd mad-pages; then
+ for page in *.md; do
+ echo " ... installing $page"
+ cp -f $page $path/$page
+ done
+ echo " ... complete"
+ else
+ echo " ... failed!" >&2
+ fi
echo
}
@@ -136,10 +138,13 @@ install_all_remote() {
install_mad() {
echo
echo " ... cloning repo"
- cd /tmp && rm -fr mad
+ cd /tmp && rm -fr mad || exit 3
git clone --depth 1 $REMOTE_MAD mad
- cd mad && make install
- echo " ... updated to $(mad --version)"
+ if cd mad && make install; then
+ echo " ... updated to $(mad --version)"
+ else
+ echo " ... failed to update!" >&2
+ fi
echo
}

0 comments on commit 296fd39

Please sign in to comment.