Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encountered error message: invalid integer constant #7

Open
Wakotu opened this issue Oct 21, 2024 · 1 comment
Open

Encountered error message: invalid integer constant #7

Wakotu opened this issue Oct 21, 2024 · 1 comment

Comments

@Wakotu
Copy link

Wakotu commented Oct 21, 2024

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
Copy link
Author

Wakotu commented Oct 21, 2024

It seems a bug happened in entry rank updating stage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant