From: no.top.post on
In article <slrnhjupoh.71m.BitTwister(a)wb.home.test>, Bit Twister <BitTwister(a)mouse-potato.com> wrote:

> On Sat, 2 Jan 2010 10:06:24 +0000 (UTC), no.top.post(a)gmail.com wrote:
> > In article <slrnhjsluq.9l6.BitTwister(a)wb.home.test>, Bit Twister <BitTwister(a)mouse-potato.com> wrote:
> ====
> >> That file could be an array of phrases.
> > Bash already handles one-phrase-per-line.
> > It's pointless to introduce the low-level concept of arrays.
>
> I have no idea where your head is at.
>
> I would have assumed your code would provide a
> index_number "Phrase string Here"
> for display and you would be passing index_number around for phrase
> selection.
>
> If the index_number is not an array index, it would have to be line
> number into a file or in your case "boj". Your choice.

NO, I specified 'bash'.
'lines' are at BASH101. If they exists at all for bash, arrays are
deeper concepts. I want to avoid getting sucked into deep-bash.

> >> Your other apps call boj which loads/displays boj.array.
> > If boj's data is IN boj then it won't get lost and I can find it by:
> > 'whereis boj'
>
> Yes. So does locate boj.data

'whereis + locate' is conceptually-DOUBLE 'whereis',
"boj" + "boj.data" is conceptually-DOUBLE "boj".
So you've got 4 times the cognitive load !!
But most importantly AFAIK 'whereis' is more primitive
hence faster and more reliable ? KISS.

> In your scenario, you have self modifying code.

! NO! having data bundled in the same file as the executable
code is NOT 'self modifying code'.
Has your digital watch got 'self modifying code' ?

> Here is a possible race condition.
> user one opens boj to add phrase, user two opens boj to add phase,
> user one closes boj with new phrase, user two closes boj wiping out
> user one's new phrase.

OK, that's an explanation for some-one who doesn't know WHAT
race-conditions are. Altho' I'm a single user [inevitably /root] I do
in fact have such conflicts, because I need to pass data between
linux and 2 other 'systems which ride on top of linux'.
And a task which I started yesterday, and is suspended for ideas,
can't keep the common-scratch-pad, which is needed for other
tasks. Apparently 'locks' are used to help. But this seems unrelated
to my OP?

I was not looking for a CS answer, but rather a bash answer.
So, I had to spend hours trying to reunderstand and modify
similar bash which I'd previously written.
IMO bash is a dog: like pre-structured-code-era BASIC.
It easily gives you the illusion that you know what you're doing.