[gobolinux-users] Gobo wants you! (to comment its scripts)
Michael Homer
michael at gobolinux.org
Sat Apr 12 20:28:15 NZST 2008
On Sat, Apr 12, 2008 at 8:14 PM, Daniele Maccari <gobo.users at gmail.com> wrote:
> Michael Homer wrote:
> > Anything that has an effect beyond returning a value (by output or by
> > return). Changing variable definitions, outputting to the user (also
> > what Show_Version does), terminating the script are all side effects.
> >
> So, for example, Add_Option updates the options arrays: has it to be
> considered a side effect?
> I'd say yes, since arrays are global to the whole script.
Hmm. Possibly (technically, yes), although those arrays are internal
to the function, rather than part of the interface. I was more
thinking of functions like String_To_Array, which also defines an
array, but one you're meant to use.
I would note anything that you would or should notice as a caller, and
leave out anything specific to the internals of the function. There's
no real encapsulation in bash, so it's a bit of a judgment call which
category any one thing fits into.
> As a side note, I could have inserted some blank lines between chunks of
> code when I felt them a bit "compressed", this making them not so
> clear/readable. Please let me know what you think about this.
I don't have an opinion on that in the general case. If it's unclear
as a big block, add a blank line, but don't go crazy with it.
> Last but not least, I've got a little doubt about what this piece of
> code does, could you please help me? http://pastebin.com/m78380740
>
> If I got it right, it loops through the current string's characters to
> find a valid shortening. At the end, if none was found, it "Log_Error"s
> the failure. What I cannot understand is why looping for all characters,
> shouldn't an option be identified by its first character only? Though
> maybe I'm missing the eval option=\${${i}} part.
It loops for compressed short options (which I didn't know we
supported), and eats the rest of the string/the next parameter if it
hits an Entry or List item. Think of it working like `tar -xjvf
file.tar.bz2`; x,j,v are Boolean options that are enabled, f is an
Entry item that eats the next parameter (and breaks from the loop over
characters).
-Michael
More information about the gobolinux-users
mailing list