Ohhhhh I see, now that's something new to me... I have to find other occurences of that very syntax to fully understand it... *le dramatic sigh*
Yeah, that's simple script coding magic for you
, able to surprise you with unknown tricks years after practising scripting...
Never ever gets boring. Nice, eh?
Anyhow, since the script is written by you (my mistake in misunderstanding that detail) , it still would be helpful when you sent it to me for examination. (Via PM) Especially when you documented it well, meaning explained in-script most of what the lines are about, what they should accomplish.
I know, most coders [incl. yours truly, being guilty of documenting less that could be documented - compared to what could be done in that regard] are lazy when it comes to documentation, but the more, the better. You now get your code, but what if an bug appears months later, due to some changes in your environment, or due to changes to bash, or due to something else entirely?
Often, then, months or even years later, a programmer not really knows/recalls what all his / her lines are meant to be; then (s)he has more or less grand issues debugging the code.
Is bash still complaining about the syntax error you posted above?
The tricky thing, at times, with syntax errors is that, unlike one might think, at times the bug is not
in the blamed line, but some other lines prior to that, but first occurs to bash as syntax error in the line bash prints to you.
That often happens when forgetting or including a " or ' [or ( as part of ) ]too much, or missing one.
Only a line or lines later, when a new, seemingly unrelated " or ' is used, bash connects both thinking they belong together, making, to bash, the later line a "syntax error", when the later line by itself is okay, and the error resulting in the missing character a line or lines above.
Hope you get what I mean by that. Sadly, I cannot think of an example. I had such bugs on a regular basis, over my years coding, but since they are bugs, I exterminate them as swoon as bash tells me about a syntax error, never tried conserving any such bug for documentation or teaching purposes...-
But even without you having documented your script, as soon as you comment at least the main basic goal of the main segments of your script, In still could be able to debug it.
[And as long as bash complains about a syntax error, there is a bug; like I tried explaining above, most often the bug really is in the line bash blames and prints out, but at times the bug itself is in other lines.
What is helpful here is a IDE or at least an editor that not only highlights codes, but also prints in colour the corresponding character to a pair of characters, like highlighting the closing ) when the cursor is at/above the starting ( .
mc's internal editor, mcedit [some info: "man mcedit"], does so. And sure, the genius IDE geany [man geany for basic info, geany is no longer by default part of Porteus, but I very much recommend it you you!] does so, too.
- Code: Select all
rava@porteus:/usr/local/bin$ file sil thumbnails.sh tzacpi
sil: Bourne-Again shell script, ISO-8859 text executable
thumbnails.sh: Bourne-Again shell script, ASCII text executable
tzacpi: POSIX shell script, ASCII text executable
rava@porteus:/usr/local/bin$ head -n 1 sil thumbnails.sh tzacpi
==> sil <==
==> thumbnails.sh <==
==> tzacpi <==
See? To "file" sil
differ. Still, both are : Bourne-Again shell scripts, or for short, bash scripts. I guess you realize in what they differ even when all info you can go with is the above first line and what file tells us?
I think we best should move this thread staring at a certain point to "programming" since it became mostly a matter of scripting/programming, and less about "KDE" or "Desktop help". Feel free to do the move, as you can do so same as me, or else I do the move when figured out where the thread became mainly a matter of coding and less a matter of the current forum's. Maybe the whole thread should be moved, even.
Just too tired ATM to get that perfectly right, but will do so in a few hours, unless you did move it prior me doing so, that is.