Using AudioScope.sh on Ubuntu 17.04 from a live DVD disc I came across an error.
Consider the code below it is a MUCH shortened version of the KEYBOARD input in AudioScope.
When run in OSX 10.12.5 this is the expected result:-
When run in Linux Mint 18 I get the same expected result from a LIVE DVD:-
HOWEVER running from a Ubuntu 17.04 current LIVE DVD This is what ensues:-
NOTE the error:- ./kb_loop.sh: line 11: break: only meaningful in a `for', `while', or `until' loop
And it keeps looping with the same error.
Is this a bug in bash 4.4.5, as bash 4.3.42 and presumably earlier is perfectly fine?!
At what point between 4.3.42 and 4.4.5 would this have broken I wonder?
What it says is perfectly true: 'break' is only meaningful inside a 'for', 'while', or 'until' loop. You can't use it to break a loop outside of your function.
It shouldn't have accepted that before, and probably wasn't doing quite exactly what you planned. You should use return codes instead, to inform whatever's calling keyboard whether it succeeded or failed. That will let you ditch the 'status' variables as well.
Your loop should instead look something like
And the function would be
Last edited by Corona688; 05-24-2017 at 02:07 PM..
These 3 Users Gave Thanks to Corona688 For This Post:
(On holiday at the moment so a limited reply.)
Well what should have happened until bash version 4.4.5 and what actully happens is not the same.
Resukts:-
This is the same on bash version 4.3.42.
The status is/was exactly as I want it except I have changed the code now whilst away on a break!
Will be home again soon and get back to you fully...
(On holiday at the moment so a limited reply.)
Well what should have happened until bash version 4.4.5 and what actually happens is not the same.
That it ever worked is, without exaggeration, the worst BASH bug I have seen to date. That behavior is explicitly barred in every language I know, SH, C, AWK, PERL -- even tinkertoys like Forth where I often wish it wasn't. break should not leap outside its local context into brave new worlds. Control statements control local blocks only.
Quote:
The status is/was exactly as I want it except I have changed the code now whilst away on a break!
I'm sorry, but there's nothing for it but to change your ways. You were relying on accidental, broken behavior. Your code will benefit greatly from learning how to use exit codes.
Last edited by Corona688; 05-26-2017 at 01:29 PM..
Still on a break with limited internet access but my 'ways are now changed'... ;o)
Well using the return method suits me fine.
I had no idea that this bug was near decades old and I was _exploiting_ it.
Thanks for pointing me in the right direction.
Here is a slightly simplified version of yours using dash as the prime mover.
OSX 10.12.5, default bash terminal calling 'dash' from the script...
I still get my variables where I want them so I am a happy bunny...
Thank you.
This User Gave Thanks to wisecracker For This Post:
AudioScope Project.
(Apologies for any typos.)
For the few following......
AudioScope.sh...
Now at Version 0.60.00.
Well this baby has come a long way since its inception in January 2013. It is now at Version 0.60.00. It is MUCH more Apple centric now with a new OSX Sierra minimum _silent_... (7 Replies)
Boy oh boy, with only a MONO mic input to use AudioScope gets much more difficult when the ALTDC board is included.
It needs, so far, two hits at the MIC input with a single hit at the HEADPHONE audio output.
The first at the highest practical resolution for the AC component and the second... (0 Replies)
I am wondering if someone can help me out. I am new to oracle and given a task to install Oracle 11g on Solaris. I am running into some major problems since last week since I can't seem to get it to work.
I can't start GUI, tried different blogs but no luck. Then, I decided to install it in a... (4 Replies)
# check host value regex='^(||1|2|25)(\.(||1|2|25)){3}$' if ')" != "" ]; then if ]; then echo host $host not found exit 4 fi elif ]; then echo $host is an invalid host address exit 5 fi
espeacailly the top regex part?
---------- Post updated at 06:58 PM ---------- Previous update was... (1 Reply)
I downloaded and installed "Cygwin yesterday onto my PC running Windows XP. When I tried to type "vi" in Cygwin's window, I got the following message bash: vi: Command not found
What shud i do inorder to get into vi editor
Thanks (10 Replies)
foreach x ( *.foo)
echo "move file?"
set move=$<
if($move == y) then
echo "enter new pathname:"
set path=$<
mv $x $path/$x
endif
end
ok guys, im creating this script so i can move files with *.foo extensions and *.bar... (6 Replies)
Hello,
basically what this script is supposed to do is showing a list of hosts that is given a number, that you will be able to choose from a list.
A check is made to verify that the chosen number is within the array and this is where things go bad and I don't know why, bizarre.
I've spent... (5 Replies)
Discussion started by: gand
5 Replies
8. Post Here to Contact Site Administrators and Moderators
When searching for new posts, I see that my voting in one of the polls counts as a 'new post'. However, while the '<blah> minutes ago' entry updates correctly, the 'by <username>' is the last user to actually post a comment in the poll instead.
Result:
Poll: vB Guest Book 39... (4 Replies)