Are you sure, that the code being executed is inside a bash function? From my understanding of the bash man page, LINENO is not defined outside of functions.
#!/bin/bash
echo "arg count = $#"
while [ $# -gt 0 ]
do
echo "$1 on $LINENO "
shift
done
exit
output:
$ ./t.shl 1 2 3
arg count = 3
1 on 5
2 on 5
3 on 5
So, I'm confused.
According to the maintainers of bash and my Cygwin version of bash, the LINENO variable always exists. So, until Annacreek can tell us the information Don Cragun asked, we cannot know what shell is being used. I would guess the shell is not bash, if in fact the problem line of code actually gets executed when the script runs.
You are right! LINENO also works well outside a function.
As for finding out whether or not you are running bash, there are several ways. First of all, you are running the script, so I would say you know what you are using. There is no magic in this.
Aside from this, you could output the variable BASH_VERSION (which would be empty, unless someone malevolently sets it explicitly). You can also trigger a syntax error in the script; if it is bash, the error message will contain the word "bash".
'$LINENO is bash "system" variable but I cannot get any output trying to use it."
OK, I did not say "I am using bash ".
Yes, being a geenie I thought
# denotes comments, apparently not.
So I moved
#!/bin/bash back as first line in file
Here is a code snippet :
czechlist_DEBUG(){
64 echo "czechlist_DEBUG "
65 echo "Passed parameter #1 is $1"
66 echo "Passed parameter #2 is $2"
67 echo "Passed parameter #3 is $3"
68 echo "Passed parameter #4 is $4"
69
70 echo "arg count = $#"
initialize while "count"
71 while [ $# -gt 0 ]
72 do
73 echo "$1 on $LINENO "
echoes "first" parameter "found" , so the construct
is
while
do
...
done
??
74 shift
75 done
76 echo " DONE line output "
77
78 pause
And here is an output , getting there:
czechlist_DEBUG
Passed parameter #1 is DEBUG USB
Passed parameter #2 is lsusb
Passed parameter #3 is test par 2
Passed parameter #4 is test par 3
arg count = 4
DEBUG USB on 73
lsusb on 73
test par 2 on 73
test par 3 on 73
DONE line output
Press [Enter] key to continue...