aboutsummaryrefslogtreecommitdiff
path: root/sbodl
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2019-12-22 08:49:06 -0500
committerB. Watson <yalhcru@gmail.com>2019-12-22 08:49:06 -0500
commita94461e02fa0fd918e01bd80f9e65bc63e2c9d4e (patch)
tree4fe2b1b3336f808d4ee290cae8f62c472e5c0cda /sbodl
parent9004e3f6e43266c2fd23be6ff8c8bcc6805c1aa4 (diff)
downloadsbostuff-a94461e02fa0fd918e01bd80f9e65bc63e2c9d4e.tar.gz
handle broken symlinks, change cache dir
Diffstat (limited to 'sbodl')
-rwxr-xr-xsbodl14
1 files changed, 11 insertions, 3 deletions
diff --git a/sbodl b/sbodl
index def7c7e..3d1e4e0 100755
--- a/sbodl
+++ b/sbodl
@@ -1,17 +1,19 @@
#!/bin/bash
-# sbodl, initial public release.
+# sbodl, download slackbuilds.org source files
+# 20191222 bkw: handle broken symlinks in current dir.
+# change default cache dir.
# 20170306 bkw: add caching
SELF=$( basename $0 )
-CACHEDIR=/home/urchlay/slackbuilds
+CACHEDIR=~/sbodl-cache
usage() {
cat <<EOF
$SELF - download the sources for a slackbuilds.org build.
-version 20170306, public release, with cachedir
+version 20191222, public release, with cachedir
(c) 2014 B. Watson (yalhcru at gmail dawt cawm)
Licensed under the WTFPL: Do WTF you want with this.
@@ -37,6 +39,8 @@ die() {
exit 1
}
+[ -d "$CACHEDIR/" ] || mkdir -p $CACHEDIR || die "Can't create $CACHEDIR"
+
# check for our one argument
case "$1" in
-h|-help|-\?|--help) usage ;;
@@ -80,6 +84,10 @@ for dl in $DL; do
esac
FILE=$( echo "$dl" | sed 's,.*/,,' )
+
+ # ignore (rm) broken symlinks
+ [ -L "$FILE" ] && ! [ -e "$FILE" ] && FORCEDL=yes
+
[ "$FORCEDL" = "yes" ] && rm -f "$FILE"
if [ -e "$FILE" ]; then