Consider:
#!/bin/bash echo ' ' $LINENO echo '' ' ' $LINENO
The first echo correctly prints a 4, but the second echo prints a 5 instead of 6. Am I missing something, or is this a bug? (Using bash 3.00.15)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It looks like an implementation misfeature (bug) in bash.
I used:
which yielded:
Which supports the theory that the variable is evaluated before the shell considers the line to have been completed. Once the line has been completed, it updates the LINENO and proceeds.
Bash versions tested: 3.2.48 (mac), 4.1.5 (linux)
When I use the syntax:
it gets the newer line number. It seems to be related to the evaluation of the empty string carried as the only argument on the line.