Pburn, Pfind, Pmusic

These are all zigbert's applications:

Pburn upgraded to v 2.0.0.

Pfind upgraded to v4.2.

Pmusic upgraded to v0.2.2.

Posted on 24 Aug 2008, 20:26


Posted on 24 Aug 2008, 22:27 by Zigbert
massive updates
There has become several small bugs, because Puppy 4.1 does not allow redirection to itself. Like this:

cat myfile.txt | grep something > myfile.txt

I have looked through my code, and updated Pfind, Pfilesearch, Pbackup, Pburn and Pmusic.

I would kindly ask you to update one more time.


Posted on 25 Aug 2008, 7:33 by BarryK
Zigbert, yes, that is a very old trap for the unwary. You have to redirect to another file first, then you must have 'sync' if the first line has piping:

cat myfile1 | grep something > myfile2
mv -f myfile2 myfile1

You can only leave off the 'sync' if piping is not used:

grep something myfile1 > myfile2
mv myfile2 myfile1

A way to avoid the sync is this:

TEMP1="`cat myfile1 | grep something`"
echo "$TEMP1" > myfile2

...but you sometimes need to be careful that the code within the "``" may be interpreted subtly differently than before -- meaning that it has to be all carefully tested.

Posted on 25 Aug 2008, 13:36 by Zigbert
let's sync
Ooookey :)

That's why you 'sync' so much. I have not synced when piping, but it still seems to work. When will I meet trouble?

And why did it work from Puppy 0.96 until Puppy 4.1 ???

Thanks for the explanation.


Posted on 25 Aug 2008, 17:46 by BarryK
Re: sync
The problem of redirecting a file into itself has always been there. If it hasn't caused you trouble, you're lucky. Or maybe some unexplained behaviour sometimes now has an explanation.

I am not certain if the sync is still needed. I discovered the problem back when we used Busybox Ash, before we had Bash in Puppy. When a line of code in a script has piping, the script may continue to execute the next line before the pipe has fully flushed, thus causing a file to be incorrect.

However, maybe Bash does not have this problem? I always play safe and put the sync in.