phpsg.sh: Remove extra slashes to normalize path.

This commit is contained in:
Nicolás A. Ortega Froysa 2025-02-19 08:41:34 +01:00
parent 1704ae6a5c
commit f5fe72a2a1

View File

@ -36,10 +36,10 @@ while getopts "o:s:j:h" opt
do do
case "$opt" in case "$opt" in
o) o)
OUTPUT_DIR="${OPTARG}" OUTPUT_DIR="$(echo "${OPTARG}" | sed 's:/*$::')"
;; ;;
s) s)
SOURCE_DIR="${OPTARG}" SOURCE_DIR="$(echo "${OPTARG}" | sed 's:/*$::')"
;; ;;
j) j)
JOBS="${OPTARG}" JOBS="${OPTARG}"
@ -67,7 +67,7 @@ export SOURCE_DIR
while IFS= read -r -d '' dir while IFS= read -r -d '' dir
do do
OUT_DIR="${OUTPUT_DIR}/${dir:${#SOURCE_DIR}}" OUT_DIR="${OUTPUT_DIR}/${dir:((${#SOURCE_DIR} + 1))}"
if ! [ -d "$OUT_DIR" ] if ! [ -d "$OUT_DIR" ]
then then
mkdir -p "$OUT_DIR" mkdir -p "$OUT_DIR"
@ -78,7 +78,7 @@ function process_file() {
file="$1" file="$1"
if [[ $file = *.php ]] if [[ $file = *.php ]]
then then
DEST_FILE="${OUTPUT_DIR}/${file:${#SOURCE_DIR}:-4}" DEST_FILE="${OUTPUT_DIR}/${file:((${#SOURCE_DIR} + 1)):-4}"
if ! [ "$file" -nt "$DEST_FILE" ] if ! [ "$file" -nt "$DEST_FILE" ]
then then
return return
@ -87,7 +87,7 @@ function process_file() {
php "$file" > "$DEST_FILE" php "$file" > "$DEST_FILE"
echo "done" echo "done"
else else
DEST_FILE="${OUTPUT_DIR}/${file:${#SOURCE_DIR}}" DEST_FILE="${OUTPUT_DIR}/${file:((${#SOURCE_DIR} + 1))}"
if ! [ "$file" -nt "$DEST_FILE" ] if ! [ "$file" -nt "$DEST_FILE" ]
then then
return return