Finding programming errors is hard
Finding programming errors is hard
When writing a program in bash or gtkdialog3, the programmer sometimes has a bad time with errors as all errors are not shown when running the program from a terminal.
An error is shown. It might be a configuration file input error where the values you think are being passed are not.
It might be something else.
But fix one error and another that was not reported shows up.
I think some users really do not appreciate the effort that goes into writing a program, or for that matter, an OS that just works.
It is not as simple as it seems.
Rant ended.
An error is shown. It might be a configuration file input error where the values you think are being passed are not.
It might be something else.
But fix one error and another that was not reported shows up.
I think some users really do not appreciate the effort that goes into writing a program, or for that matter, an OS that just works.
It is not as simple as it seems.
Rant ended.
Re: Programming errors
Bash programmers may wish to look at this: http://bashdb.sourceforge.net/8-bit wrote:When writing a program in bash or gtkdialog3, the programmer sometimes has a bad time with errors as all errors are not shown when running the program from a terminal.
______
Dennis
Re: Programming errors
Maybe I downloaded the wrong file, but when I tried to compile it, it said bash in puppy was not a new enough version.DMcCunney wrote:Bash programmers may wish to look at this: http://bashdb.sourceforge.net/8-bit wrote:When writing a program in bash or gtkdialog3, the programmer sometimes has a bad time with errors as all errors are not shown when running the program from a terminal.
______
Dennis
So I will see if an older version is offered.
Re: Programming errors
I compiled it awhile ago I think back on puppy 3.018-bit wrote:Maybe I downloaded the wrong file, but when I tried to compile it, it said bash in puppy was not a new enough version.DMcCunney wrote:Bash programmers may wish to look at this: http://bashdb.sourceforge.net/8-bit wrote:When writing a program in bash or gtkdialog3, the programmer sometimes has a bad time with errors as all errors are not shown when running the program from a terminal.
______
Dennis
So I will see if an older version is offered.
I havent used it since then
I just write in small sections at a time and echo out stuff to verify things
and with every edit make a new file so you can always go back to where it worked
I just wrote a package management tool I studied how it worked for months... before writing one line of code yes it is work but you gotta love it
make a dragN drop script for testing
Code: Select all
#!/bin/bash
xterm -geometry 100x10+10+20 -e sh -x "$@"
also you could also do this overkill but sometimes you need it
Code: Select all
rxvt -geometry 90x30+650+40 -e /usr/bin/strace /usr/share/doc/gtkdialog3/examples/01.00-button
where /usr/share/doc/gtkdialog3/examples/01.00-button
could be a bash script gtkdialog or whatever executble
Joe
Last edited by big_bass on Fri 30 Apr 2010, 17:45, edited 2 times in total.
- Pizzasgood
- Posts: 6183
- Joined: Wed 04 May 2005, 20:28
- Location: Knoxville, TN, USA
You can use the set -x command to enable debug mode (and set +x to disable it). Alternately, to enable it for the entire script, add the -x to the shebang, ala #!/bin/sh -x
That way the program will automatically echo some information about each command before it is executed, and expands all variables. That can help with figuring out what's going on.
That way the program will automatically echo some information about each command before it is executed, and expands all variables. That can help with figuring out what's going on.
[size=75]Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib[/size]
[img]http://www.browserloadofcoolness.com/sig.png[/img]
[img]http://www.browserloadofcoolness.com/sig.png[/img]
- RetroTechGuy
- Posts: 2947
- Joined: Tue 15 Dec 2009, 17:20
- Location: USA
You're working on the command line? Can you not scroll backwards with the mouse roller? (there is no scroll bar on the side, but it will roll back with the scroll function -- under 4.3.1, anyway).8-bit wrote:Thank you Pizzasgood!
Now that is a very useful piece of information.
One problem though.
Most of the time, that info is displayed and disappears before you can grasp it.
I will try it though.
I often expand the rxvt window to full screen, so it limits the number of wrapped lines.
You could alternatively redirect the errors to a log file of some sort.
- Sit Heel Speak
- Posts: 2595
- Joined: Fri 31 Mar 2006, 03:22
- Location: downwind
I`ve use Bash debugging, but so often you need to know the output or value of something.
Nothing replaces the good old "echo" command for really knowing what`s going on...
In Visual Basic you can "swipe highlight" a variable, equation, or an entire line to get it`s value.
And of course Basic`s : break, line watch, and stepping control. A "posh" environment...
Nothing replaces the good old "echo" command for really knowing what`s going on...
In Visual Basic you can "swipe highlight" a variable, equation, or an entire line to get it`s value.
And of course Basic`s : break, line watch, and stepping control. A "posh" environment...
If bash write error messages to standard error, "sh -x script 2> error.log" should capture the error messages.8-bit wrote:Thank you Pizzasgood!
Now that is a very useful piece of information.
One problem though.
Most of the time, that info is displayed and disappears before you can grasp it.
I will try it though.
Alternatively, "sh -x script | tee script.log" should capture the output in script.log as well as showing it on screen.
______
Dennis
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
if you want a gui if there are errors you can check if "`cat error.log`" != "" and then display it with Xdialog --infobox ...or something similar (xmessage, yafsplash...) the only problem is some commands that use stderr instead of stdout (ffmpeg comes to mind if I recall correctly)
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].
- Pizzasgood
- Posts: 6183
- Joined: Wed 04 May 2005, 20:28
- Location: Knoxville, TN, USA
You can scroll (even on the raw commandline w/o X) by pressing Shift and the Page Up or Page Down buttons. Useful sometimes.
[size=75]Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib[/size]
[img]http://www.browserloadofcoolness.com/sig.png[/img]
[img]http://www.browserloadofcoolness.com/sig.png[/img]
- prehistoric
- Posts: 1744
- Joined: Tue 23 Oct 2007, 17:34
combining error output, "state"
If you want the error and standard output to be combined for debugging, you can, of course, append this to the command.technosaurus wrote:...the only problem is some commands that use stderr instead of stdout (ffmpeg comes to mind if I recall correctly)
Code: Select all
2>&1
By the time you get to distributed systems where different parts of the state are at different places, and accessed at different times, the concept of state is no longer simple. I have witnessed a room full of PhDs arguing about what one object in a distributed system "knew" about the state of another object. It sounded a lot like arguments about what is "really going on" in quantum mechanics and relativity.
Beware of code that places great demands on this kind of memory and understanding.
- RetroTechGuy
- Posts: 2947
- Joined: Tue 15 Dec 2009, 17:20
- Location: USA
Re: combining error output, "state"
Thanks Prehistoric. That jogged my memory... Which helped me find these:prehistoric wrote:If you want the error and standard output to be combined for debugging, you can, of course, append this to the command.technosaurus wrote:...the only problem is some commands that use stderr instead of stdout (ffmpeg comes to mind if I recall correctly)Although I am no longer actively programming, aging has taught me, by reducing my working memory, that errors in state-based reasoning are behind many bugs like those discussed here. If you are dealing with simple machines with a single program counter directly executing straight-forward machine code, the idea of state seems pretty simple. The x86 series is no longer so simple, even without complicated systems software.Code: Select all
2>&1
By the time you get to distributed systems where different parts of the state are at different places, and accessed at different times, the concept of state is no longer simple. I have witnessed a room full of PhDs arguing about what one object in a distributed system "knew" about the state of another object. It sounded a lot like arguments about what is "really going on" in quantum mechanics and relativity.
Beware of code that places great demands on this kind of memory and understanding.
http://www.linuxsa.org.au/tips/io-redirection.html
http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-3.html