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.
The line number in the script or shell function currently executing.
Example script
output:
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".
This isn't just bash... It was in ksh before 1988, and the latest POSIX standard says the following about the LINENO variable:
Quote:
Set by the shell to a decimal number representing the current sequential line number (numbered starting with 1) within a script or function before it executes each command. If the user unsets or resets LINENO, the variable may lose its special meaning for the life of the shell. If the shell is not currently executing a script or function, the value of LINENO is unspecified. ...
So, I guess we should also ask for the output from the command:
hoping to verify that the script doesn't assign any value to LINENO and doesn't use unset with LINENO as an operand.
This User Gave Thanks to Don Cragun For This Post:
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
Display the contents of all files ending in a number to the screen
2. Relevant commands, code, scripts,... (2 Replies)
Discussion started by: marcincan
2 Replies
2. Post Here to Contact Site Administrators and Moderators
I have many files .dat extension.
requirement is to display line no
if no of delimiter does not matches in a given variable
lets say
File: REF_BETOS.dat
HCPCS_OR_CPT_CODE~BETOS_CODE~TERMINATION_DATE
0001F~Z2~
0003T~I4~B20061231
0005F~Z2~~~
0008T~P8~B20061231... (1 Reply)
Hello,
I'm using ls -laR to print out a list of file and folders. I want to print only the permission, file size and file name. Also, excluding the '.' and '..'.
result from ls -laR:
total 6
drwxr-xr-x 8 user staff 512 Nov 28 16:17 .
drwxr-x--- 16 user staff 1024... (3 Replies)
Hello I'm new to this forum. So please spare me!
I'm using SCO UnixWare 7.1.4 and created a few accounts. So far so good.
When I login I see: $.
But here I want to see (for example),
/home
25$
So I want to see the pathname where I am without each time typing pwd (2 Replies)
I don't see any threads like this and I know that a bunch of people have really cool desktops, so I`ll start.
rules
1 no images in your post,attachments only
2 no default desktops, tha would be very much a waste (2 Replies)