• Login
Community
  • Login

Function List incomplete

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
25 Posts 3 Posters 2.2k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G
    greg-michael @Michael Vincent
    last edited by Jun 9, 2023, 8:32 PM

    @Michael-Vincent Part 5

    ################################################################################
    # ptc_symlink
    ################################################################################
    ptc_symlink()
    {
    print_msg "\n(${MM}/${DD} $(date +%R)) Started ptc_symlink" "debug"
    
    unset BASELINKCMD DELLINKCHK DSSVR LINKCHK LINKCMDOUT
    
    local BASELINKCMD="${(e)LINKCMD}"
    local DELLINKCHK=""
    local DSSVR="${1}"
    local LINKCHK=""
    local LINKCMDOUT=""
    
    # Check for existence of /opt/mqm symbolic link to /usr/mqm/MQCV
    LINKCHK="$( find //${DSSVR}/opt -maxdepth 1 -type l -ls 2>/dev/null | grep -icE 'lrwx.*mqm[ \t]*->' )"
    
    print_msg "BASELINKCMD=${(e)BASELINKCMD}~nLINKCHK=${LINKCHK}~nOPTDIR=${OPTDIR}~n\
    UNINSTALL=${UNINSTALL}" "debug"
    
    if [[ ${UNINSTALL} == 1 && ${LINKCHK} == 1 ]]
      then
        # Uninstalling - remove symbolic link
        BASELINKCMD='find /opt -maxdepth 1 -type l -ilname '*mqm*' -exec /bin/rm -vf {} \;'
        if (( DRYRUN ))
          then
            print_msg "\nnexec -i -l ${DSSVR} \"${(e)BASELINKCMD}\"" "dryrun"
          else
            LINKCMDOUT="$( nexec -i -l ${DSSVR} ${(e)BASELINKCMD} )"
            print_msg "BASELINKCMD=${(e)BASELINKCMD}~nLINKCMDOUT=${LINKCMDOUT}" "debug"
            DELLINKCHK="$( ${LINKCHK} | grep -icE '^l.*mqm ->' )"
            if [[ ${DELLINKCHK} != 0 ]]
              then
                ERRORDESC="ERROR 125: Failed to remove /opt/mqm symbolic link on ${DSSVR}"
                let ERROR_CODE=125
                if [[ -n "${LINKCMDOUT}" ]] ; then print_msg "LINKCMDOUT=\n${LINKCMDOUT}" ; fi
                critical_error
            fi
        fi
      elif [[ ${UNINSTALL} == 0 ]]
        then
          if [[ ${OPTDIR} == 1 ]]
            then
              # Force uninstallation of PTC MQ Client from /opt/mqm
              export UNINSTALL=1
              rollback_mq ${DSSVR}
              # Reset UNINSTALL and OPTDIR values
              export UNINSTALL=0
              export OPTDIR=0
              # Create symbolic link for /opt/mqm -> /usr/mqm/MQCV
              ptc_symlink ${DSSVR}
              # Reset environment checks
              env_check ${DSSVR}
            elif [[ ${LINKCHK} == 0 ]]
              then
                print_msg "Symbolic link not found in /opt/mqm on ${DSSVR} - creating it"
                unset LINKCHK
                if (( DRYRUN ))
                  then
                    print_msg "\nnexec -i -l ${DSSVR} \"${(e)BASELINKCMD} ; sleep 5\"" "dryrun"
                  else
                    LINKCMDOUT="$( nexec -i -l ${DSSVR} "${(e)BASELINKCMD} 2>/dev/null \
    ; echo -e \"RESULT=\$?\" ; sleep 5 ; ${FINDCMD} /opt -maxdepth 1 -type l -ilname '*mqm*' -ls 2>/dev/null" )"
    
                    let LINKCHK="$( find //${DSSVR}/opt -maxdepth 1 -type l -ls 2>/dev/null | \
    grep -icE 'l[wrx]{3}.*mqm ->' )"
    
                    print_msg "BASELINKCMD=${(e)BASELINKCMD}~nLINKCHK=${LINKCHK}~n\
    LINKCMDOUT=${LINKCMDOUT}" "debug"
    
                    if [[ ${LINKCHK} == 0 ]]
                      then
                        ERRORDESC="ERROR 124: Failed to create /opt/mqm symbolic link on ${DSSVR}"
                        let ERROR_CODE=124
                        if [[ -n "${LINKCMDOUT}" ]] ; then print_msg "LINKCMDOUT=\n${LINKCMDOUT}" ; fi
                        critical_error
                    fi
                fi
          fi
    fi
    
    print_msg "\n(${MM}/${DD} $(date +%R)) End ptc_symlink" "debug"
    }
    ################################################################################
    # fix_install
    ################################################################################
    fix_install()
    {
    print_msg "\n(${MM}/${DD} $(date +%R)) Started fix_install" "debug"
    
    unset FIXFILE FIXRPMS FIXRPMSBASE FIXRPMSFP FIXSVR MQFIXCMD MQFIXCMDOUT
    
    local FIXFILE="${MQINSTBASE}${MQVERSION}.tar.gz"
    local FIXRPMS="${2}"
    local FIXRPMSBASE=""
    local FIXRPMSFP=""
    local FIXSVR="${1}"
    local MQFIXCMD=""
    local let MQFIXCMDOUT=99
    
    FIXRPMS="$( for rpm in $(echo -e "${FIXRPMS}") ; do echo -n "${rpm}${RPMSUFFIX} " ; done )"
    #GVM#FIXRPMSBASE="$( echo -e "${FIXRPMS}" | grep -ivE "(BES|${MQVERBASEERE}[^0])" | tr -s '\n' ' ' )"
    #GVM#FIXRPMSFP="$( echo -e "${FIXRPMS}" | grep -ivE "(BES|${MQVERBASEERE}0)" | tr -s '\n' ' ' )"
    FIXRPMSBASE="$( for rpm in $( echo -e "${FIXRPMS}" ) ; do echo -n "${DATAPATH}/MQCV/${rpm}" | \
    grep -ivE "(BES|${MQVERBASEERE}[^0])" ; done )"
    
    FIXRPMSBASE="$( echo -e "${FIXRPMSBASE}" | tr '\n' ' ' )"
    FIXRPMSFP="$( for rpm in $( echo -e "${FIXRPMS}" ) ; do echo -n "${DATAPATH}/MQCV/${rpm}" | \
    grep -ivE "(BES|${MQVERBASEERE}0)" ; done )"
    
    FIXRPMSFP="$( echo -e "${FIXRPMSFP}" | tr '\n' ' ' )"
    MQFIXCMD="${RPMINST} --force ${FIXRPMSFP} 2>&1 ; echo -e \"RESULT=\$?\""
    print_msg "FIXFILE=${FIXFILE}~n\nFIXRPMS=${FIXRPMS}~n\nFIXRPMSBASE=${FIXRPMSBASE}~n\
    \nFIXRPMSFP=${FIXRPMSFP}~nFIXSVR=${FIXSVR}~n\nMQFIXCMD=${MQFIXCMD}~nMQFIXCMD=${MQFIXCMD}" "debug"
    
    if (( DRYRUN ))
      then
        print_msg "copy_files ${FIXSVR} ${SOURCESVR} \"${(e)SOURCEDIR}${PATCHVER}\" \"${FIXFILE}\"" "dryrun"
        print_msg "MQFIXCMDOUT=\"\$( nexec -i -l ${FIXSVR} \"${MQFIXCMD}\" )\"" "dryrun"
      else
        copy_files ${FIXSVR} ${SOURCESVR} "${(e)SOURCEDIR}${PATCHVER}" "${FIXFILE}"
        MQFIXCMDOUT="$( nexec -i -l ${FIXSVR} "${MQFIXCMD}" )"
        print_msg "\nMQFIXCMDOUT=${MQFIXCMDOUT}" "debug"
        if [[ $( echo -e "${MQFIXCMDOUT}" | grep -i "RESULT=" | \
    sed 's/[[:cntrl:]]*//g' | cut -f2 -d'=' ) != 0 ]]
    
          then
            ERRORDESC="ERROR 140: Errors detected after fixing install on ${FIXSVR}"
            let ERROR_CODE=140
            if [[ -n "${MQFIXCMDOUT}" ]] ; then print_msg "MQFIXCMDOUT=\n${MQFIXCMDOUT}" ; fi
            critical_error
        fi
    fi
    
    print_msg "\n(${MM}/${DD} $(date +%R)) End fix_install" "debug"
    }
    ################################################################################
    # Main
    ################################################################################
    # Check for log path. Create if not found.
    if [[ -d '/tmp' ]]
      then
        export LOGPATH='/tmp'
      elif [[ -d '/C/Temp' ]]
        then
          export LOGPATH='/C/Temp'
    fi
    if [[ ! -d "${LOGPATH}" ]] ; then mkdir -p "${LOGPATH}" ; fi
    
    # Files
    LOGFILE="${LOGPATH}/${NSH}.${MMDD}"
    MAILFILE="${LOGPATH}/${NSH}.mail"
    TMPLOG="${LOGPATH}/${NSH}.$$.${MMDD}${YYYY}${HH}${MIN}.log"
    
    # Clean up prior log file
    if [[ -f ${TMPLOG} ]] ; then rm -f ${TMPLOG} ; fi
    
    print_msg "\n(${MM}/${DD} $(date +%R)) Started ${NSH}"
    
    # Validate number of arguments given
    if [[ ! $# -ge 2 ]] ; then let ERROR_CODE=0 ; usage ; fi
    
    # leading ':' enables quiet processing with '?' and ':' as values when problems
    # are encountered.
    # trailing ':' indicates that an option requires an argument.
    while getopts ":dhp:Rs:Uy" OPT
       do
         case "${OPT}" in
             d|D) # Enable DEBUG
                  let DEBUG=1
                  print_msg "DEBUG MODE ENABLED"
                  print_msg "DEBUG=${DEBUG}" "debug"
                  ;;
             h|H) # Help/usage
                  usage
                  ;;
             p|P) # Patch version to install
                  if [[ $( awk -v num=${OPTARG} 'BEGIN {if (num ~ /[0-9]+/) { print "1" }}' ) == 1 ]]
                    then
                      let PATCHVER=${OPTARG}
                      print_msg "PATCHVER=${PATCHVER}" "debug"
                    else
                      ERRORDESC="ERROR 100: Unrecognized Patch Version: ${OPTARG}"
                      let ERROR_CODE=100
                      critical_error
                  fi
                  ;;
               R) # Rollback/uninstall MQ Client
                  let ROLLBACK=1
                  print_msg "ROLLBACK PROCESSING"
                  print_msg "ROLLBACK=${ROLLBACK}" "debug"
                  ;;
             s|S) # Host list
                  HOSTS="${OPTARG}"
                  if [[ $( echo -e "${HOSTS}" | awk '{if ($0 ~ /(,|;|:|\t)/) {print "1"} else {print "0"}}' ) -ge 1 ]]
                    then
                      HOSTS="$( echo -e "${HOSTS}" | tr -s ',:;\t' ' ' )"
                  fi
                  print_msg "HOSTS=${HOSTS}" "debug"
                  ;;
               U) # Uninstall MQ Client
                  let UNINSTALL=1
                  print_msg "UNINSTALL PROCESSING"
                  print_msg "UNINSTALL=${UNINSTALL}" "debug"
                  ;;
             y|Y) # Enable DRYRUN
                  let DRYRUN=1
                  print_msg "Executing DRYRUN"
                  print_msg "DRYRUN=${DRYRUN}" "debug"
                  ;;
             \?) # Invalid option
                  print_msg "Invalid option ${OPTARG} provided"
                  usage
                  ;;
             \:) # Missing required argument to option
                  print_msg "Option ${OPTARG} requires an argument."
                  usage
                  ;;
         esac
    done
    
    # remove processed options leaving what remains as $@
    shift $(( OPTIND - 1 ))
    if [[ -n "$@" ]] ; then print_msg "\$@=$@" "debug" ; fi
    
    # ROLLBACK and UNINSTALL are mutually exclusive
    if [[ ${UNINSTALL} == 1  && ${ROLLBACK} == 1 ]]
      then
        print_msg "Rollback and Uninstall options are mutually exclusive"
        usage
    fi
    
    # Check for tarball on source server
    # (e) Perform parameter expansion, command substitution and arithmetic expansion
    # on the result.
    #
    # Expected tar file name format: MQCV-9.2.0-X.tar.gz
    #
    TARBALL="$( ls //${SOURCESVR}${SOURCEPATH} 2>/dev/null | \
    grep -iE "${(e)SOURCEFILES}" | sed 's/[[:cntrl:]]*//g' | sort -d )"
    
    TARNUM=$( echo -e "${TARBALL}" | grep -icE "${(e)SOURCEFILES}" )
    
    #GVM#print_msg "\nTARBALL=\n$( echo -e "${TARBALL}" | sed 's/\(^.*$\)/\\t\1/g' )\
    #GVM#~nTARNUM=${TARNUM}" "debug"
    print_msg "~nTARBALL=\n$( echo -e "${TARBALL}" | sed 's/\(^.*$\)/\\t\1/g' )\
    ~nTARNUM=${TARNUM}" "debug"
    
    # If PATCHVER is not passed in as an argument, determine most recent patch level
    # based on tarball name on source server
    if [[ ${TARNUM} -ge 1 && ${PATCHVER} == 0 ]]
      then
        let PATCHVER="$( echo -e "${TARBALL}" | tail -n 1 | awk '{
    print substr($0,index($0,".tar.gz")-1,1) }' )"
    
        print_msg "PATCHVER=${PATCHVER}" "debug"
    fi
    
    # Validate PATCHVER is set and use it to set TARFILE
    if [[ ${PATCHVER} == 0 ]]
      then
        ERRORDESC="ERROR 101: Failed to set Patch Version"
        let ERROR_CODE=101
        critical_error
      else
    #GVM#    TARFILE="$( echo -e "${TARBALL}" | grep -iE "${MQVERBASE}${PATCHVER}" )"
    #GVM#    TARFILE="$( echo -e "${TARBALL}" | grep -iE "${MQVERBASEERE}${PATCHVER}" )"
        TARFILE="$( echo -e "${TARBALL}" | \
    grep -iE "${MQVERBASEERE}${PATCHVER}" | sed 's/[[:cntrl:]]*//g' | tail -n 1 )"
    #GVM#    print_msg "TARFILE=${TARFILE}" "debug"
        if [[ ! -n ${TARFILE} ]]
          then
            ERRORDESC="ERROR 102: Failed to set TARFILE"
            let ERROR_CODE=102
            critical_error
          else
            # (e) expand variable first
            # #*- strip off all characters up to and including the first '-'
            # /.tar.gz search and remove '.tar.gz'
            # %-* print all characters up to and including the first '-'
            # starts with MQCV-9.3.0-4.tar.gz
            # ends with 9.3.0-
            MQVERBASE="$( echo -e "${${${(e)TARFILE#*-}/.tar.gz}%-*}-" )"
            # strip all '.' and '-' characters
            typeset -i BASECMDLVL=$( echo -e "${MQVERBASE}" | tr -d '.-' )
            MQUPBASE="U$( echo -e "${BASECMDLVL}" )"
            print_msg "TARFILE=${TARFILE}~nBASECMDLVL=${BASECMDLVL}~nMQUPBASE=${MQUPBASE}\
    ~nMQVERBASE=${MQVERBASE}" "debug"
    
        fi
    fi
    
    # Build RPM lists
    if (( ! UNINSTALL ))
      then
        for rpm in ${MQRPMS}
           do
             RPMINSTLIST+="${DATAPATH}/MQCV/${rpm}${MQINSTBASE}${MQVERBASE}${MQVERBASEMIN}${RPMPLATFORM}\
    ${RPMSUFFIX} "
    
             RPMUPLIST+="${DATAPATH}/MQCV/${rpm}${MQINSTBASE}${MQUPBASE}${PATCHVER}-\
    ${MQVERBASE}${PATCHVER}${RPMPLATFORM}${RPMSUFFIX} "
    
        done
        print_msg "\nRPMINSTLIST=${RPMINSTLIST}~n\nRPMUPLIST=${RPMUPLIST}" "debug"
    fi
    
    # Process hosts list one server at a time
    for host in ${HOSTS}
       do
         print_msg "Processing ${host}"
         # Validate environment
         env_check ${host}
         # If uninstalling or rolling back
         if (( ROLLBACK || UNINSTALL ))
           then
             # If no install is found
             if [[ ${EXISTING} == 0 && ${NEWINST} == 0 ]]
               then
                 print_msg "No installations of MQ Client found on ${host}"
               # Verify requested version to rollback matches installed version
    #GVM#           elif (( PATCHVER < VER && MAJVER >= 9 ))
               elif [[ ${BASECMDLVL}${PATCHVER} < ${MAXCMDLVL}${VER} && ${MAJVER} -ge 9 ]]
                 then
                   ERRORDESC="ERROR 103: Requested version to rollback \
    \"${MQVERBASE}${PATCHVER}\" is below installed version \"${MQVERBASE}${VER}\""
    
                   let ERROR_CODE=103
                   critical_error
                 else
                   # Perform rollback on host
                   rollback_mq ${host}
             fi
           # If host is already running requested patch version
    #GVM#       elif [[ ${PATCHVER} == ${VER} ]]
           elif [[ ${BASECMDLVL}${PATCHVER} == ${MAXCMDLVL}${VER} ]]
             then
               print_msg "${host} is already running version ${MQVERBASE}${PATCHVER}"
               if (( BESINSTALL )) ; then install_bes ${host} ; fi
             else
               # Install or apply Fix Pack
               # Create /opt/mqm symbolic link for PTC environment
               if (( PTC )) ; then ptc_symlink ${host} ; fi
               # Copy files to target
               # Avoid copying files twice if BASECMDLVL > MAXCMDLVL (9.3.0 > 9.2.0)
    #GVM#           if [[ ${ROLLBACK} == 0 && ${UNINSTALL} == 0 ]]
               if [[ ${ROLLBACK} == 0 && ${UNINSTALL} == 0 && ${BASECMDLVL} > ${MAXCMDLVL} ]]
                 then
    #GVM#               copy_files ${host} ${SOURCESVR} "${SOURCEDIR}${PATCHVER}" "${TARFILE}"
                   copy_files ${host} ${SOURCESVR} "${(e)SOURCEDIR}${PATCHVER}" "${TARFILE}"
               fi
               # Install BESAgent if not installed
               if (( BESINSTALL )) ; then install_bes ${host} ; fi
    #GVM#           if (( NEWINST ))
               if [[ ${NEWINST} == 1 || ${MAXCMDLVL} < ${BASECMDLVL} ]]
                 then
                   # New install
                   install_mq ${host} "${RPMINSTLIST}"
                 else
                   # Fix Pack install
                   install_mq ${host} "${RPMUPLIST}"
               fi
               # Clean up RPMs and tarballs
               # ':=' If unset or null, set DATAPATH to /var/mqm to prevent any possibility
               # of acting on files in the / file system
               if (( DRYRUN ))
                 then
    #GVM#               print_msg "\nnexec -i -l ${host} \"/bin/rm -dfR \
    #GVM#${DATAPATH:=/var/mqm}/MQCV ; /bin/rm -dfR ${DATAPATH:=/var/mqm}/BESClient\"" "dryrun"
                   print_msg "\nnexec -i -l ${host} \"/bin/rm -dfR \
    ${DATAPATH:=/var/mqm}/MQCV ; /bin/rm -f ${DATAPATH:=/var/mqm}/MQCV-*.*.*-*.tar.gz ; \
    /bin/rm -dfR ${DATAPATH:=/var/mqm}/BESClient\"" "dryrun"
    
                 else
    #GVM#               nexec -i -l ${host} "/bin/rm -dfR ${DATAPATH:=/var/mqm}/MQCV ; \
    #GVM#/bin/rm -dfR ${DATAPATH:=/var/mqm}/BESClient"
    #GVM#               nexec -i -l ${host} "/bin/rm -dfR ${DATAPATH:=/var/mqm}/MQCV ; \
    #GVM#/bin/rm -f ${DATAPATH:=/var/mqm}/MQCV-*.*.*-*.tar.gz ; /bin/rm -dfR ${DATAPATH:=/var/mqm}/BESClient"
                   nexec -i -l ${host} "${(e)CLEANCMD}"
               fi
         fi
         # Skip copying log file for dry run
         if (( ! DRYRUN ))
           then
             if (( UNINSTALL ))
               then
                 cp ${TMPLOG} //${host}${MQCVPATH}/${NSH}.${MMDD}${YYYY}${HH}${MIN}.uninstall.log
               else
                 cp ${TMPLOG} //${host}${MQCVPATH}/${NSH}.${MMDD}${YYYY}${HH}${MIN}.log
             fi
         fi
    done
    
    print_msg "\n(${MM}/${DD} $(date +%R)) Finished ${NSH}"
    #-------------------------------------------------------------------------------
    # Retention is listed below at 90 days for logs and datafiles. Ask user of
    # process for actual retention specifications and change accordingly.
    #-------------------------------------------------------------------------------
    CURRDIR="${PWD}"
    cd "${LOGPATH}"
    find -path "${LOGPATH}" \( -name ${NSH}'.*.log' -o -name 'delete.*' \) -mtime +90 \
    -exec /bin/rm -f {} \; 2>>${LOGPATH}/delete.${MMDD}
    
    cd "${CURRDIR}"
    
    # Process log files and exit
    critical_error
    #END
    
    M 1 Reply Last reply Jun 9, 2023, 9:10 PM Reply Quote 0
    • M
      Michael Vincent @greg-michael
      last edited by Jun 9, 2023, 9:10 PM

      @greg-michael

      I think something went wrong with the cut and pastes, from line 403 on it lexes as a string:

      6f87ede3-fe92-413e-88e4-4da88782d6d3-image.png

      G 1 Reply Last reply Jun 9, 2023, 11:53 PM Reply Quote 0
      • M
        MAPJe71
        last edited by Jun 9, 2023, 10:20 PM

        The following two lines in the ptc_symlink-function are the problem:

        LINKCMDOUT="$( nexec -i -l ${DSSVR} "${(e)BASELINKCMD} 2>/dev/null \
        ; echo -e \"RESULT=\$?\" ; sleep 5 ; ${FINDCMD} /opt -maxdepth 1 -type l -ilname '*mqm*' -ls 2>/dev/null" )"
        

        When you escape two additional double-quotes, refresh or save the file, the fix_install-function is listed
        e.g.

        LINKCMDOUT="$( nexec -i -l ${DSSVR} \"${(e)BASELINKCMD} 2>/dev/null \
        ; echo -e \"RESULT=\$?\" ; sleep 5 ; ${FINDCMD} /opt -maxdepth 1 -type l -ilname '*mqm*' -ls 2>/dev/null\" )"
        
        G 1 Reply Last reply Jun 9, 2023, 11:49 PM Reply Quote 1
        • G
          greg-michael @MAPJe71
          last edited by greg-michael Jun 10, 2023, 12:18 AM Jun 9, 2023, 11:49 PM

          @MAPJe71 Interesting… I have a few other lines throughout the script that utilize the same syntax structure I believe. Why wouldn’t those functions be affected the same way? For example, lines #370-#375, lines #814-#815, lines #1271-#1272, line #1321, line #1333, and lines #1384-#1385.

          For what it’s worth, I’ll explain what the line is doing from an application perspective.

          This script runs in BMC’s TrueSight Server Automation as an NSH script. NSH is based on the ZShell. The syntax of the command is such that the subshell command “nexec” is doing a remote shell execution on a target server to create a symbolic link, echo the result with a “RESULT=” prefix, waits 5 seconds, and then does a find command to list out the contents of the /opt path looking for symbolic links.

          The output looks similar to this:

          RESULT=0
          nexec -i -l algebs.ds.cpr.ca "/bin/find /opt -type l -ilname '*mqm*' -ls"
                867      0 lrwxrwxrwx   1  mqm      mqm            21 Nov  9  2021 /opt/mqm/bin -> /usr/mqm/MQSV9202/bin
          

          Thanks!

          M 1 Reply Last reply Jun 10, 2023, 9:45 PM Reply Quote 0
          • G
            greg-michael @Michael Vincent
            last edited by Jun 9, 2023, 11:53 PM

            @Michael-Vincent said in Function List incomplete:

            @greg-michael

            I think something went wrong with the cut and pastes, from line 403 on it lexes as a string:

            I went back and copied that section of pasted code separately from the forum post into a new Shell-formatted document in NP++ and it looked normal. Did you possibly miss a starting quote in the copy/paste from the forum into your NP++?

            1 Reply Last reply Reply Quote 0
            • M
              MAPJe71 @greg-michael
              last edited by Jun 10, 2023, 9:45 PM

              @greg-michael

              Any part of the source that matches the commentExpr of the parser is skipped during the search for class, method and function definitions.
              For the majority of the available parsers this feature is used to prevent detection of function definitions in text definitions (aka string literals). The detection of string literals highly depends on the proper i.e. quote balanced text definitions. Any improper definition can lead to all kinds of unexpected results.

              For instance double quoted string literals start and end with a double quote and any double quote within must be escaped.

              AFAICT a lot of the double quoted string definitions in the provided source contain un-escaped double quotes.

              G 1 Reply Last reply Jun 12, 2023, 4:05 PM Reply Quote 2
              • G
                greg-michael @MAPJe71
                last edited by Jun 12, 2023, 4:05 PM

                @MAPJe71 said in Function List incomplete:

                For instance double quoted string literals start and end with a double quote and any double quote within must be escaped.

                This is true, except when using a subshell call : $( … ). The double quotes within the subshell execution are treated separately from the string literal definition. At least that’s the way I’ve learned to use them in Shell scripting.

                AFAICT a lot of the double quoted string definitions in the provided source contain un-escaped double quotes.

                For those strings within a string, yes, they are escaped. For those commands being executed within a subshell call, and the results being returned and stored as a String, no.

                M 1 Reply Last reply Jun 12, 2023, 7:40 PM Reply Quote 0
                • M
                  MAPJe71 @greg-michael
                  last edited by MAPJe71 Jun 12, 2023, 7:41 PM Jun 12, 2023, 7:40 PM

                  @greg-michael

                  those strings within a string

                  for the parser (presuming ... does not contain double quotes):
                  string_literal_name=" ... \" ... \" ... "
                  string_literal_name="${ ... \" ... \" ... }"
                  and those strings within a string within a string:
                  string_literal_name="${ ... \" ... \\\" ... \\\" ... \" ... }"

                  commands being executed within a sub shell call, and the results being returned and stored as a String

                  string_literal_name=${ ... }

                  The parser will see at least two string literals in the following line:
                  string_literal_name="${ part1 " part2 " part3 }"
                  i.e. "${ part1 " and " part3 }"

                  G 1 Reply Last reply Jun 13, 2023, 6:00 PM Reply Quote 2
                  • G
                    greg-michael @MAPJe71
                    last edited by Jun 13, 2023, 6:00 PM

                    @MAPJe71 said in Function List incomplete:

                    for the parser (presuming ... does not contain double quotes):
                    string_literal_name=" ... \" ... \" ... "
                    string_literal_name="${ ... \" ... \" ... }"
                    and those strings within a string within a string:
                    string_literal_name="${ ... \" ... \\\" ... \\\" ... \" ... }"

                    commands being executed within a sub shell call, and the results being returned and stored as a String

                    string_literal_name=${ ... }

                    The parser will see at least two string literals in the following line:
                    string_literal_name="${ part1 " part2 " part3 }"
                    i.e. "${ part1 " and " part3 }"

                    Is it safe to assume that your use of the curly braces in lieu of the parentheses is accidental?

                    M 1 Reply Last reply Jun 13, 2023, 10:01 PM Reply Quote 0
                    • M
                      MAPJe71 @greg-michael
                      last edited by Jun 13, 2023, 10:01 PM

                      @greg-michael Yes

                      1 Reply Last reply Reply Quote 0
                      25 out of 25
                      • First post
                        25/25
                        Last post
                      The Community of users of the Notepad++ text editor.
                      Powered by NodeBB | Contributors