Skip to content

Instantly share code, notes, and snippets.

@fuzzy
Created August 5, 2012 16:07
Show Gist options
  • Save fuzzy/3265555 to your computer and use it in GitHub Desktop.
Save fuzzy/3265555 to your computer and use it in GitHub Desktop.
lndir in Sh
slndir() {
if [ -z "${1}" ] || [ -z "${2}" ]; then
echo 'Usage: slndir /dir1 /dir2/'
else
SRC=${1}
if [ "${2}" = "." ] || [ "${2}" = "./" ]; then
DST=${PWD}
else
DST=${2}
fi
tmp=$(mktemp /tmp/cpkg.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX)
echo ${PWD} > ${tmp}
cd ${SRC}
for itm in $(ls); do
if [ -x ${DST}/${itm} ] && [ -d ${DST}/${itm} ]; then
`slndir ${SRC}/${itm} ${DST}/${itm}`
else
ln -s ${d}/${itm} ${DST}/${itm}
fi
done
cd $(cat ${tmp})
rm -f ${tmp}
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment