Changeset 3596 for trunk


Ignore:
Timestamp:
Jan 22, 2025, 3:46:20 PM (40 hours ago)
Author:
jbclement
Message:

COMMON:
Making the Fortran file automatically generated at compilation more robust regarding backslashes + Gathering all characters modification in a function to be clearer.
JBC

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.COMMON/makelmdz_fcm

    r3595 r3596  
    608608current_date=$(date)
    609609
     610# Function to process problematic characters
     611#     Delete invalid character due to encoding format
     612#     Escape backslashes and single quotes
     613clean_output() {
     614    echo "$1" \
     615        | iconv -f "$(locale charmap)" -t UTF-8//IGNORE \
     616        | sed 's/\\/\\\\/g; s/'\''/'\'\''/g'
     617}
     618
    610619# Iterate through subdirectories in $LMDGCM/../ to determine version control system
    611620vcs_info=""
     
    619628    # Determine the version control system for each subdirectory
    620629    if command -v svn > /dev/null && svn info "$dir" > /dev/null 2>&1; then # SVN
    621         vcs_info+="\n-> SVN Information for \"$(basename "$dir")\"\n$(svn info "$dir" | iconv -f "$(locale charmap)" -t UTF-8//IGNORE)\n"
    622         vcs_diff+="\n-> SVN Diff for \"$(basename "$dir")\"\n$(svn diff "$dir" | iconv -f "$(locale charmap)" -t UTF-8//IGNORE)\n"
    623         vcs_stat+="\n-> SVN Status for \"$(basename "$dir")\"\n$(svn status "$dir" | iconv -f "$(locale charmap)" -t UTF-8//IGNORE)\n"
     630        vcs_info+="\n-> SVN Information for \"$(basename "$dir")\"\n$(svn info "$dir" | clean_output)\n"
     631        vcs_diff+="\n-> SVN Diff for \"$(basename "$dir")\"\n$(svn diff "$dir" | clean_output)\n"
     632        vcs_stat+="\n-> SVN Status for \"$(basename "$dir")\"\n$(svn status "$dir" | clean_output)\n"
    624633    elif command -v git > /dev/null && git -C "$dir" rev-parse --is-inside-work-tree > /dev/null 2>&1; then # Git
    625         vcs_info+="-> Git Information for \"$(basename "$dir")\"\n$(git -C "$dir" log -1 --pretty=format:"%H%n%an%n%ad%n%s" | iconv -f "$(locale charmap)" -t UTF-8//IGNORE)\n"
    626         vcs_diff+="\n-> Git Diff for \"$(basename "$dir")\"\n$(git -C "$dir" diff | iconv -f "$(locale charmap)" -t UTF-8//IGNORE)\n"
    627         vcs_stat+="\n-> Git Status for \"$(basename "$dir")\"\n$(git -C "$dir" status --short | iconv -f "$(locale charmap)" -t UTF-8//IGNORE)\n"
     634        vcs_info+="-> Git Information for \"$(basename "$dir")\"\n$(git -C "$dir" log -1 --pretty=format:"%H%n%an%n%ad%n%s" | clean_output)\n"
     635        vcs_diff+="\n-> Git Diff for \"$(basename "$dir")\"\n$(git -C "$dir" diff | clean_output)\n"
     636        vcs_stat+="\n-> Git Status for \"$(basename "$dir")\"\n$(git -C "$dir" status --short | clean_output)\n"
    628637    else # None
    629638        vcs_info+="\n-> No version control system for \"$(basename "$dir")\"\n"
     
    667676    echo "write(*,'(a)') '=== Version Control Information ==='" >> "$info_file"
    668677    while IFS= read -r line; do
    669         echo "write(*,'(a)') '${line//\'/\'\'}'" >> "$info_file"
     678        echo "write(*,'(a)') '${line}'" >> "$info_file"
    670679    done <<< "$(echo -e "$vcs_info")"
    671680else
     
    679688    echo "open(unit = 1, file = \"${res_file}\",status = 'replace',action = 'write')" >> "$info_file"
    680689    while IFS= read -r line; do
    681         echo "write(1,'(a)') '${line//\'/\'\'}'" >> "$info_file"
     690        echo "write(1,'(a)') '${line}'" >> "$info_file"
    682691    done <<< "$(echo -e "$vcs_stat")"
    683692    echo "close(1)" >> "$info_file"
     
    690699    echo "open(unit = 1, file = \"${res_file}\",status = 'unknown',position = 'append',action = 'write')" >> "$info_file"
    691700    while IFS= read -r line; do
    692         echo "write(1,'(a)') '${line//\'/\'\'}'" >> "$info_file"
     701        echo "write(1,'(a)') '${line}'" >> "$info_file"
    693702    done <<< "$(echo -e "$vcs_diff")"
    694703    echo "close(1)" >> "$info_file"
Note: See TracChangeset for help on using the changeset viewer.