adding repl_links
This commit is contained in:
parent
57e548f4e9
commit
005a695848
1 changed files with 31 additions and 0 deletions
31
shell/repl_links.sh
Executable file
31
shell/repl_links.sh
Executable file
|
|
@ -0,0 +1,31 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# take a given directory and replace all symlinks with their real
|
||||||
|
# counterparts; replace a symlink to a file with the real file and
|
||||||
|
# a symlink to a directory with the real one.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
ROOT=$1
|
||||||
|
|
||||||
|
LINKS=$(find "${ROOT}" -type l -printf "%p\n")
|
||||||
|
|
||||||
|
OLDIFS=$IFS
|
||||||
|
IFS=$'\012'
|
||||||
|
|
||||||
|
for link in ${LINKS}; do
|
||||||
|
if [ -d "${link}" ]; then
|
||||||
|
echo "dir: ${link}"
|
||||||
|
mv "${link}" "${link}.sym"
|
||||||
|
mkdir "${link}"
|
||||||
|
cp -LcdpR "${link}.sym"/* "${link}/"
|
||||||
|
elif [ -f "${link}" ]; then
|
||||||
|
echo "file: ${link}"
|
||||||
|
mv "${link}" "${link}.sym"
|
||||||
|
cp -Lcp "${link}.sym" "${link}"
|
||||||
|
else
|
||||||
|
echo "unknown: ${link}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
IFS=${OLDIFS}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue