Please - this is my FIRST ever attempt on scrip and I just want simple answer if possible.
I am modifying existing and working script.
I just want to and more to it so I started with simple insertion of working code into menu.
I am doing OK, but I cannot figure out why I am executing this line of code
I understand the "end of case" , but || (or?) does not makes sense to me for now.
I am enclosing PART what I feel is an "problem area"
I am coding in C/C++ and know about switch / case construct , but I do not understand why duplicating item 9 and inserting it as item 10 is causing this error. It should just run same function as item 9 does.
The "menu" displays OK , but when I select the item 10 I get the DEBUG ERROR message. Is it possible I am getting the "programmer error ..." also but it is getting overridden by the next message?
Help will be much appreciated.
The || is the "control operator" in a bash "OR list". man bash:
Quote:
An OR list has the form
command1 || command2
command2 is executed if and only if command1 returns a non-zero exit status.
So the construct is there to catch errors of case dealing with the various FUNs.
Be aware that $FU$ will expand to just $ (unless FU is defined somewhere in your script).
Try moving the second msgbox to another position to eliminate your "override suspicion"
Does your case work for other inputs, e.g. 3 , or 9 ? What exactly do you enter in either case, and what in the 10 case?
Are you aware that the shown snippet only has some improvement opportunities?
Thanks for reply.
(URL deleted - not allowed ) It never occurred to me that case returns value.
I'll follow you suggestions after I post this.
I am modifying "standard" configuration file to make sense of WiFi errors I am getting.
I am not too concerned if the file is perfect, I just need to make my modifications for now.
Would it be feasible to implement something like this - in pseudocode ?
When I gain some more experience I would like to make the "|| command " as a function passing the error number (?) and the variable message to it.
If you are only seeing the DEBUG ERROR message box when you run do_about, it means that do_about is exiting with a non-zero exit code. The exit status of a case statement is the exit status of the last command executed in the command list for the matched pattern or zero if no pattern matched.
The text you included in post #3 in this thread (that Neo edited for you to contain CODE tags) did indeed include the shell script pseudo-code which without CODE tags displays as:
...
esac || if debug
print error code
else
just print the original message
With CODE tags that pseudo-code appears as:
Please use CODE tags when displaying sample input, sample output, and code (or pseudo-code) segments.
In the bash menu below if the variant that is inputted is in the format NM_004004.3:c.274G>T the below works perfectly. My question is if the variant inputted isNM_004004.3:-c.274G>T or NM_004004.3:+c.274G>T then the code as is will throw an error due to a biological issue. Is it possible to to... (1 Reply)
Hi Gurus,
I have the below BASH code which does not works for upper case alphabets except Z (upper case Z).
What may be the reason. Also escape sequences like \n, \t, \b, \033(1m \033(0m (For bold letter) are not working.
case $var in
)
echo "Lower case alphabet"
;;
... (7 Replies)
Hi,
I'm having some trouble with using "case...esac" in Bash.
I've googled it and am stuggling to understand the syntax and how to do certain things.
Firstly, I want to be able to choose a case based on a variable number
For example, I have in my code a place where a user can enter... (2 Replies)
Hello All,
I am writing a script that is to be placed on multiple servers, and of course I've started
running into some compatibility issues for certain shell commands.
The code below worked just fine on most of my machines except for a couple.
Here I had 4 separate lines in my script that... (3 Replies)
I have the following bash script and it is not accepting the lines
"--"|"--""-")
"--""-"")
while
do
echo "Current Argument is ${1}"
case "$1" in
"--"|"--""-")
echo "Argument is ${1}"
shift # Skip ahead one to the next argument.
... (1 Reply)
I'm pretty sure I already know the answer to this, but I want to make sure I'm not overlooking anything. I'm working on a log monitoring script and every 10 lines I want to display a summary of events. The thing is, there are a lot of possible events, that likely won't have happened, so I only want... (0 Replies)
Is there any inbuilt functionality in Unix shell script so that i can able to convert lower case string input to an upper case?
I dont want to use high level languages like java,python or perl for doing the job. (2 Replies)
greetings,
I have a script that is taking input like this:
a
b
c
d
aa
bb
aaa
bbb
ccc
ddd
and formating it to be like this:
a b c d
aa bb
aaa bbb ccc ddd (4 Replies)
It can get very annoying that bash regex =~ is case-sensetive, is there a way to set it to be case-insensetive?
if ]; then
echo match
else
echo no match
fi (8 Replies)