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

error message for $(( a )) doesn't have location #664

Closed
andychu opened this issue Mar 15, 2020 · 4 comments
Closed

error message for $(( a )) doesn't have location #664

andychu opened this issue Mar 15, 2020 · 4 comments

Comments

@andychu
Copy link
Contributor

andychu commented Mar 15, 2020

14.2 Empty variables in arithmetic expressions

The second most type of warnings is this.

$ osh -c 'a=; echo $((a))'
[??? no location ???] warning: Invalid integer constant ''

Originally posted by @akinomyoga in #653 (comment)

@andychu andychu changed the title error message for (( a )) doesn't have location error message for $(( a )) doesn't have location Mar 15, 2020
@andychu
Copy link
Contributor Author

andychu commented Mar 15, 2020

BTW this behavior could be relaxed, e.g. hidden behind shopt -s strict_arith. It depends how many programs are broken by it.

But it is probably better to get through the high priority (double star) issues on #653 before working on that.

@andychu
Copy link
Contributor Author

andychu commented Mar 21, 2020

After fixing the location. I think the EXIT and RETURN need to be turned into associative arrays, not indexed arrays?

$ ~/git/oilshell/oil/bin/osh -O parse_unimplemented
[osh] lisa ~/git/wild/ble.sh$ source out/ble.osh
    ((!fail))
       ^~~~
out/ble.osh:224: warning: Invalid integer constant ''
    ((!fail))
       ^~~~
out/ble.osh:224: warning: Invalid integer constant ''
      _ble_builtin_trap_signames[index]=$name
                                 ^
[ array LValue in out/ble.osh ]:1833: warning: Invalid integer constant 'EXIT'
      _ble_builtin_trap_signames[index]=$name
                                 ^
[ array LValue in out/ble.osh ]:1833: warning: Invalid integer constant 'RETURN'
      builtin printf -v ret '%d' "'${1:$2:1}"
                                       ^~
out/ble.osh:4619: warning: Invalid integer constant ''
      builtin printf -v ret '%d' "'${1:$2:1}"
                                       ^~
out/ble.osh:4619: warning: Invalid integer constant ''
      builtin printf -v ret '%d' "'${1:$2:1}"
                                       ^~
out/ble.osh:4619: warning: Invalid integer constant ''
      builtin printf -v ret '%d' "'${1:$2:1}"
                                       ^~
out/ble.osh:4619: warning: Invalid integer constant ''

andychu pushed a commit that referenced this issue Mar 21, 2020
This code path was tickled by ble.sh.

Addresses issue #664.

Also turn off warnings since they come up too much.  #598 to provide
strictness levels could help.
@akinomyoga
Copy link
Collaborator

akinomyoga commented Mar 21, 2020

After fixing the location. I think the EXIT and RETURN need to be turned into associative arrays, not indexed arrays?

Thank you for the report! But EXIT and RETURN must not appear here in original ble.sh. It seems there are some problems in upstream of the code, which causes the wrong values of $index.

Ah, this is caused by the format difference of trap -l between Bash and Oil. Looking at Oil trap -l outputs, ble.sh considers EXIT to be the value of ERR and RETURN to be the value of DEBUG.

bash$ builtin trap -l
 1) SIGHUP       2) SIGINT       3) SIGQUIT      4) SIGILL       5) SIGTRAP
 6) SIGABRT      7) SIGBUS       8) SIGFPE       9) SIGKILL     10) SIGUSR1
11) SIGSEGV     12) SIGUSR2     13) SIGPIPE     14) SIGALRM     15) SIGTERM
(snip)

osh$ builtin trap -l
   EXIT
   ERR
   RETURN
   DEBUG
 1 HUP
 2 INT
 3 QUIT
(snip)

@andychu
Copy link
Contributor Author

andychu commented Mar 25, 2020

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

No branches or pull requests

2 participants