strip_c_comments_safe.sh: add processing of direct (non-chained) symlinks
This commit is contained in:
1 parent
98744b340b
commit
9a9d547b84
1 file changed
+20
-4
@@ -108,6 +108,8 @@ if [[ ! -d "$TARGET_DIR" ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
TARGET_DIR=$(cd -- "$TARGET_DIR" && pwd)
|
||||||
|
|
||||||
process_file() {
|
process_file() {
|
||||||
local mode="$1"
|
local mode="$1"
|
||||||
local file="$2"
|
local file="$2"
|
||||||
@@ -432,8 +434,22 @@ if [[ "$WITH_CMAKE" -eq 1 ]]; then
|
|||||||
find_expr+=( -o -name "*.cmake" )
|
find_expr+=( -o -name "*.cmake" )
|
||||||
fi
|
fi
|
||||||
|
|
||||||
find "$TARGET_DIR" -type f \( "${find_expr[@]}" \) -print0 |
|
declare -A seen_files=()
|
||||||
|
|
||||||
while IFS= read -r -d '' file; do
|
while IFS= read -r -d '' file; do
|
||||||
mode="$(detect_mode "$file")"
|
real_file="$file"
|
||||||
[[ -n "$mode" ]] && process_file "$mode" "$file"
|
if [[ -L "$file" ]]; then
|
||||||
done
|
target=$(readlink "$file")
|
||||||
|
if [[ "$target" != /* ]]; then
|
||||||
|
dir="$(cd "$(dirname "$file")" && pwd -P)" || continue
|
||||||
|
target="$dir/$target"
|
||||||
|
fi
|
||||||
|
[[ -L "$target" ]] && continue
|
||||||
|
[[ ! -f "$target" ]] && continue
|
||||||
|
real_file="$target"
|
||||||
|
fi
|
||||||
|
[[ -n "${seen_files[$real_file]+x}" ]] && continue
|
||||||
|
seen_files[$real_file]=1
|
||||||
|
mode="$(detect_mode "$real_file")"
|
||||||
|
[[ -n "$mode" ]] && process_file "$mode" "$real_file"
|
||||||
|
done < <(find "$TARGET_DIR" \( -type f -o -type l \) \( "${find_expr[@]}" \) -print0)
|
||||||
Reference in new issue
Block a user