Script repair
This commit is contained in:
@@ -17,18 +17,13 @@
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License (./LICENSE.md).
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# FILE INFORMATION
|
||||
# DEFGROUP: MokoStandards
|
||||
# INGROUP: Generic.Script
|
||||
# REPO: https://github.com/mokoconsulting-tech/MokoStandards
|
||||
# PATH: /scripts/fix_paths.sh
|
||||
# VERSION: 01.00.00
|
||||
# BRIEF: Replace Windows-style path separators with POSIX separators in text files.
|
||||
|
||||
# =============================================================================
|
||||
# fix_paths.sh
|
||||
#
|
||||
# BRIEF: Replace Windows-style path separators with POSIX separators in text files.#
|
||||
# Purpose:
|
||||
# - Normalize path separators in text files to forward slashes (/).
|
||||
# - Intended for CI validation and optional remediation workflows.
|
||||
@@ -44,16 +39,16 @@ set -euo pipefail
|
||||
ROOT_DIR="${1:-.}"
|
||||
|
||||
info() {
|
||||
echo "INFO: $*"
|
||||
echo "INFO: $*"
|
||||
}
|
||||
|
||||
warn() {
|
||||
echo "WARN: $*" 1>&2
|
||||
echo "WARN: $*" 1>&2
|
||||
}
|
||||
|
||||
die() {
|
||||
echo "ERROR: $*" 1>&2
|
||||
exit 1
|
||||
echo "ERROR: $*" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
command -v find >/dev/null 2>&1 || die "find not available"
|
||||
@@ -63,18 +58,18 @@ command -v file >/dev/null 2>&1 || die "file not available"
|
||||
info "Scanning for text files under: $ROOT_DIR"
|
||||
|
||||
while IFS= read -r -d '' file; do
|
||||
if file "$file" | grep -qi "text"; then
|
||||
if grep -q '\\\\' "$file"; then
|
||||
sed -i.bak 's#\\\\#/#g' "$file" && rm -f "$file.bak"
|
||||
info "Normalized paths in $file"
|
||||
fi
|
||||
fi
|
||||
if file "$file" | grep -qi "text"; then
|
||||
if grep -q '\\\\' "$file"; then
|
||||
sed -i.bak 's#\\\\#/#g' "$file" && rm -f "$file.bak"
|
||||
info "Normalized paths in $file"
|
||||
fi
|
||||
fi
|
||||
done < <(
|
||||
find "$ROOT_DIR" \
|
||||
-type f \
|
||||
-not -path "*/.git/*" \
|
||||
-not -path "*/node_modules/*" \
|
||||
-print0
|
||||
find "$ROOT_DIR" \
|
||||
-type f \
|
||||
-not -path "*/.git/*" \
|
||||
-not -path "*/node_modules/*" \
|
||||
-print0
|
||||
)
|
||||
|
||||
info "Path normalization complete."
|
||||
|
||||
Reference in New Issue
Block a user