clarity20 / fasder

A descendant of fasd offering faster performance on Windows/Cygwin and (eventually) more...
MIT License
7 stars 1 forks source link

Encountered error message: invalid integer constant #7

Open Wakotu opened 1 month ago

Wakotu commented 1 month ago

following error message prompted when selecting a entry or enterinig a directory.

/usr/local/bin/fasder: line 465: ((: fRank=(10#: invalid integer constant (error token is "10#")
/usr/local/bin/fasder: line 466: ((: iCount=10#: invalid integer constant (error token is "10#")
/usr/local/bin/fasder: line 467: ((: fCount=10#000000+10#: invalid integer constant (error token is "10#")

Usage Scenario

7QZ0WZ ~44OLH3PQ}I}6VUJ 98S%2}Z1@5}H_J{%EFCDI63

OS Environment

Distributor ID: Ubuntu
Description:    Ubuntu 22.04.5 LTS
Release:        22.04
Codename:       jammy

Bug Cause

I ran the script with -x option on and notice that the value of fRank and iCount in line 465, 466,467 was empty like following

++ (( fRank=(10#)*10**d ))
/usr/local/bin/fasder: line 466: ((: fRank=(10#: invalid integer constant (error token is "10#")
++ (( iCount=10#+10#2 ))
/usr/local/bin/fasder: line 467: ((: iCount=10#: invalid integer constant (error token is "10#")
++ (( fCount=10#000000+10# ))
/usr/local/bin/fasder: line 468: ((: fCount=10#000000+10#: invalid integer constant (error token is "10#")
        # Increase the count. Be careful about precision and overflow
        ((d = scale - ${#fRank}))
        if ((d > 0)); then ((fRank = (10#$fRank) * 10 ** d)); fi
        ((iCount = 10#$iCount + 10#$iRank)) # force base-10 arithmetic
        ((fCount = 10#$fCount + 10#$fRank))

I can see that fRank seems failed to match corresponding value with regex from passed in entry, like following:

++ populate_ranks_and_times 0 '/home|2|1729432311'
++ [[ /home|2|1729432311 =~ (.*)\|(([0-9]+)(\.([0-9]*))?)\|(.*) ]]
++ fname=/home
++ iRank=2
++ fRank=
++ time=1729432311
    populate_ranks_and_times() {
      # Parse a line of fasd data
      [[ $2 =~ (.*)\|(([0-9]+)(\.([0-9]*))?)\|(.*) ]]
      fname=${BASH_REMATCH[1]}
      #rank=${BASH_REMATCH[2]}
      iRank=${BASH_REMATCH[3]}
      fRank=${BASH_REMATCH[5]}
      time=${BASH_REMATCH[6]}

But I have no idea about the situation of iCount. It seems never to be initialized with a value.

Wakotu commented 1 month ago

It seems a bug happened in entry rank updating stage.