Created
July 2, 2014 14:48
-
-
Save rhemz/ec2e1041d8be88603080 to your computer and use it in GitHub Desktop.
symlink tree
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
prog=$0 | |
srcdir=$1 | |
ignore="$2" | |
if test $# -lt 1; then | |
echo "symlink-tree error: Usage: symlink-tree srcdir \"ignore1 ignore2 ...\"" | |
exit 1 | |
fi | |
ignore_additional=". .. CVS .git .svn" | |
# If we were invoked with a relative path name, adjust ${prog} to work | |
# in subdirs. | |
case ${prog} in | |
/* | [A-Za-z]:[\\/]*) ;; | |
*) prog=../${prog} ;; | |
esac | |
# Set newsrcdir to something subdirectories can use. | |
case ${srcdir} in | |
/* | [A-Za-z]:[\\/]*) newsrcdir=${srcdir} ;; | |
*) newsrcdir=../${srcdir} ;; | |
esac | |
for f in `ls -a ${srcdir}`; do | |
if [ -d ${srcdir}/$f ]; then | |
found= | |
for i in ${ignore} ${ignore_additional}; do | |
if [ "$f" = "$i" ]; then | |
found=yes | |
fi | |
done | |
if [ -z "${found}" ]; then | |
echo "$f ..working in" | |
if [ -d $f ]; then true; else mkdir $f; fi | |
(cd $f; ${prog} ${newsrcdir}/$f "${ignore}") | |
fi | |
else | |
echo "$f ..linked" | |
rm -f $f | |
ln -s ${srcdir}/$f . | |
fi | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment