On 8/30/24 12:09, Anon Loli wrote:
On Thu, Aug 29, 2024 at 07:03:11PM -0400, Nick Holland wrote:
On 8/29/24 16:11, Anon Loli wrote:
> Okay, I have an vague idea about what happens, let me 1st add this to the bug
> report:
> > So I launched a half a dozen tmux windows and they had archivemedia script
> running and while I started all the windows, I went on to edit the script and
> add a few lines,
so...you were editing a running script?  I do believe that falls under the
category, "undefined behavior".  Yeah, I kinda expect things to go bad
when you do that.

You are probably assuming the file is loaded in RAM at start and stays there
until done.  That's not how it works, I am pretty sure I've tried it and not
got away with it before, too.

Nick.

Of course I assumed that the file would be loaded in RAM lol why wouldn't I?

oh, perhaps because you understood Unix?  Silly me, of course not.

It's the only thing that makes sense to me, but then again I don't know how
executing scripts works exactly *shrug*.

I would like to know why that is, perhaps this is already answered in e-mails
I'm yet to read, but my OS will not have this unlogical and unreliable and
actually I'm assuming that this is also UNDOCUMENTED undefined behavior, and as
such, ksh.1 manual page is at fault here, this is a bugs.

Kid, there's an unlimited number of ways to do things wrong.  man pages can't
cover all of them, especially when you make shit up.

I'd invite you to switch to Linux, except bash does the exact same thing.
I'd invent you to return to Windows, except windows batch does the exact
same thing (I once had to explain this to a person at my company's headquarters.
She'd just crashed the point of sale system at every one of our stores by
updating the nightly processing batch file while by having the batch file
copy over a new version of itself.  "D, you can't change a running batch
file".  Fortunately, I had ignored her threats of firing me for messing with
the Point of Sale system enough that I knew how to recover her error.  We
got along a LOT better after that!)
Dunno about PowerShell.  But I'd be slightly surprised if it isn't the same
"read from disk as you go".

Here's a fun demo:


$ cat a.ksh
#!/bin/ksh

echo "#!/bin/ksh" >b.ksh
echo "sleep 0.5" >>b.ksh
chmod +x b.ksh

./b.ksh &

for N in $(jot 20 1); do
    print -n '.'
    print "print $N" >>b.ksh
    print "sleep 1" >>b.ksh
    sleep 0.5
done

It's a script (a.ksh) that creates a new script (b.ksh), then executes
that new script in the background AND keeps adding to the new script. But
it adds to the new script faster than it executes it.  So most of the
code that b.ksh runs doesn't exist when it was first started.

And...works exactly the same on linux+bash (with appropriate code changes)

Nick.

Reply via email to