The time now is Tue 21 May 2013, 20:08
All times are UTC - 4 |
| Author |
Message |
zephyr2
Joined: 11 Jan 2013 Posts: 6
|
Posted: Wed 06 Feb 2013, 08:23 Post subject:
Trash problems (Solved) |
|
Right click Trash -> View Summary.
This gives empty list even if there are items in trash.
/usr/local/apps/Trash/AppRun, line 195:
cat /tmp/trashitems | sed -e 's/</?/g' | sed -e 's/>/?/g' > /tmp/trashitems
If deleting above line View Summary works ok. But that line maybe have some meaning.. how to fix it?
Also.. when dragging and dropping any item to Trash, it causes two lines appearing to /tmp/xerrs.log:
/usr/local/apps/Trash/AppRun: line 234: test: -sd: unary operator expected
/usr/local/apps/Trash/AppRun: line 120: [: =: unary operator expected
I am using Lucid 528, but tried also Precise 542 Retro live-CD.
|
|
Back to top
|
|
 |
L18L
Joined: 19 Jun 2010 Posts: 1711 Location: Burghaslach, Germany
|
Posted: Wed 06 Feb 2013, 14:03 Post subject:
Re: Trash problems Subject description: fix |
|
| zephyr2 wrote: | Right click Trash -> View Summary.
This gives empty list even if there are items in trash.
/usr/local/apps/Trash/AppRun, line 195:
cat /tmp/trashitems | sed -e 's/</?/g' | sed -e 's/>/?/g' > /tmp/trashitems
If deleting above line View Summary works ok. But that line maybe have some meaning.. how to fix it?. |
The meaning is:
print the content of file /tmp/trashitems to stream editor sed who has to change each occurance of < to ? and each > to ? and print the result to file /tmp/trashitems
if something does not happen fast enough this results in an empty file.
| my fix wrote: | #cat /tmp/trashitems | sed -e 's/</?/g' | sed -e 's/>/?/g' > /tmp/trashitems
sed -ie 's/</?/g;s/>/?/g' /tmp/trashitems
| Doing the same but smarter, -i ...... inline, both string replacements in one sed command
| zephyr2 wrote: | Also.. when dragging and dropping any item to Trash, it causes two lines appearing to /tmp/xerrs.log:
/usr/local/apps/Trash/AppRun: line 234: test: -sd: unary operator expected
/usr/local/apps/Trash/AppRun: line 120: [: =: unary operator expected. |
Did not happen again after applying above fix
I am using Precise 54
|
|
Back to top
|
|
 |
zephyr2
Joined: 11 Jan 2013 Posts: 6
|
Posted: Wed 06 Feb 2013, 14:32 Post subject:
|
|
Your fix works well also in Lucid 528. Thank you very much.
|
|
Back to top
|
|
 |
amigo
Joined: 02 Apr 2007 Posts: 1758
|
Posted: Wed 06 Feb 2013, 14:54 Post subject:
|
|
zephyr2 is right -you can't cat out of a file and back into itself at the same time. His correction works (with versions of sed which support the '-i option). sed actually creates a temp file when used with the -i option. Changing the original command to this:
| Code: | cat /tmp/trashitems | sed -e 's/</?/g' | sed -e 's/>/?/g' > /tmp/trashitems~
mv /tmp/trashitems~ /tmp/trashitems |
does exactly the same thing.
|
|
Back to top
|
|
 |
disciple
Joined: 20 May 2006 Posts: 6179 Location: Auckland, New Zealand
|
Posted: Thu 07 Feb 2013, 06:13 Post subject:
|
|
Wow, so people do use the Trash roxapp (or at least try to).
Thanks for actually reporting this.
| amigo wrote: | | zephyr2 is right -you can't cat out of a file and back into itself at the same time. |
Unfortunately in some circumstances you actually can. It always worked perfectly fine for me in my Puppy install, otherwise I wouldn't have published it like that in the first place
We already had the same discussion when someone pointed out this bug a year or so ago (I thought it was Barry, or maybe someone commenting on his blog, but I can't find it there now). Of course, the fix was pointed out too, and I figured I should probably try to get a fixed version packaged and included in Puppy, but never got around to it.
I thought I should first check exactly what Barry was using in Puppy (I know it wasn't exactly what I made) and package the update to match it. But I couldn't even find an official Puppy Trash package, so I guess it is hidden away inside something else...
And at the same time I wanted to see if I could tidy up some of the other code, and make it work using just gtkdialog for all the guis, and internationalize it as well (since Technosaurus or someone showed how to do that properly)... all this could be quite an effort for me, as I'm just an ignorant user
_________________ DEATH TO SPREADSHEETS
- - -
Classic Puppy quotes
- - -
Beware the demented serfers!
|
|
Back to top
|
|
 |
npierce
Joined: 28 Dec 2009 Posts: 633
|
Posted: Wed 13 Feb 2013, 13:16 Post subject:
|
|
I see that the main problem has been solved thanks to the multiple valid solutions proposed in this thread.
I also noticed that SFR suggested a couple of proposed solutions in another thread:
| In the Slacko-5.4 feedback and bug reports thread, SFR wrote: |
| Code: | | cat /tmp/trashitems | sed -e 's/</?/g' | sed -e 's/>/?/g' > /tmp/trashitems |
doesn't work as it supposed to, I guess.
Proposed fixes:
- To append those two sed commands to the above "long sed parade"
- Actually Gtkdialog won't mind if there will be < > chars in cat'ted string between <input>cat /tmp/trashitems</input> tags, so maybe delete the line completely..? (works for me) |
Apparently 01micko has used one of SFR's proposals in the latest Slacko beta:
SFR's second proposed fix matches the modification that zephyr2 used successfully.
SFR's suggestion that "Gtkdialog won't mind if there will be < > chars in cat'ted string between <input>cat /tmp/trashitems</input> tags" sounds right to me, although I only did some quick testing.
If that is true, this would seem to be the preferred solution, since filenames containing < and > would then display correctly in the summary window. Of course filenames with those characters should be a rare occurrence, since using those characters in filenames is not good practice. (But it is legal).
disciple, do you remember if you ran into any problems if you didn't translate those characters? Or did you add that line to be cautious, just in case those characters might cause trouble if left untranslated?
Naturally, if there is a known problem when that translation is missing, one of the other solutions would be preferred. Certainly any of the proposed solutions is much better than the status quo, where you may not see any filenames at all.
The main reason for this post is to address the error messages that zephyr2 reported, and one other that I ran into.
| zephyr2 wrote: | | /usr/local/apps/Trash/AppRun: line 120: [: =: unary operator expected |
To fix, change line 120:
| Code: | | Had desktop shortcut? = `if [ $shortcuts = "true" ]; then echo yes; else echo no; fi`" > "$HOME/.Trash/$FileName-$$/Info" |
to:
| Code: | | Had desktop shortcut? = `if [ "$shortcuts" = "true" ]; then echo yes; else echo no; fi`" > "$HOME/.Trash/$FileName-$$/Info" |
Why? If $shortcuts was never set, the test is equivalent to
which is not a valid test.
| zephyr2 wrote: | | /usr/local/apps/Trash/AppRun: line 234: test: -sd: unary operator expected |
(If you move two items to the trash, you instead get "binary operator expected", and three or more items gives you "too many arguments".)
To fix, change line 234:
to:
Why?
This is a strange one. To the best of my knowledge, there is not now, nor has there ever been an -sd test in bash. Perhaps someone more familiar with bash scripts can let me know if there ever was such a test.
This script goes back to 2005. I didn't look back that far, but I did find a version from 2006, with this line. So it has been there for years if not forever.
I have no idea why that -sd was put there.
But the code works!
It gives that error message, but it works.
At that point in the script, the $1 parameter has already been compared to all of the valid command-line options ("-look", "-summary", etc.), and none were found. So now if there are any command-line arguments, they are the names of files or directories to be deleted. And if there are no arguments, then the trash icon was clicked because the user wants to look in the trash. So this test just determines which of these two actions to take.
Since -sd is not a valid test, bash just assumes that it is a string. So if there are no arguments
is equivalent to
which is a valid test, and exits true (0) since the string is not empty. So when the script then compares the exit status with "0", it correctly takes the branch that shows the trash.
One thing here confused me at first. Since $@ is contained inside quotation marks, I would have thought that the equivalent line in this case would be:
which is not a valid test. But a look at the bash man page explained why that was not the equivalent:
| Bash Reference Manual: Special Parameters wrote: | | When there are no positional parameters, "$@" and $@ expand to nothing (i.e., they are removed). |
When there are are one or more command line arguments, the equivalent line would be something like:
| Code: | | test -sd "testfile.txt" |
which is not a valid test, and exits false (2) since it is invalid. So when the script compares the exit code to "0", it correctly takes the branch that moves the file(s) to the trash.
So, the original line, despite being invalid in bash and causing an error message, seems to work as intended.
My change simply does the same thing with valid code.
There is a similar bug in template/temp-AppRun, which is the template for the scripts that are used to restore items. Restoring an item caused an error message like this:
| Quote: | | /root/.Trash/testfile.txt-32174/AppRun: line 141: test: -sd: unary operator expected |
To fix, change line 141 in template/temp-AppRun:
to:
By the way, I am assuming that this application was never intended to be used from the command line. Although it works from the command line, it is far from bullet-proof in that case. From the command line, one can pass it fictitious filenames to move to the trash, and it will happily make entries in the trash. And, from the command line, one needs to pass the full pathname (e.g, /root/my-documents/testfile.txt), not just the filename (e.g., testfile.txt) -- if not, the file cannot be restored.
Since the intention is for files to be moved to the trash by drag-and-drop, there should not be a problem with fictitious filenames or files without the full pathname. So I've not bothered to address either of those issues here.
There is one other bug that I am aware of. Trash likes to make a rather annoying sound when trashing an item. But since some folks might consider this a feature, I have not addressed this issue either.
| disciple wrote: | | I thought I should first check exactly what Barry was using in Puppy (I know it wasn't exactly what I made) and package the update to match it. But I couldn't even find an official Puppy Trash package, so I guess it is hidden away inside something else... |
Yes. It is included in Woof:
http://bkhome.org/fossil/woof2.cgi/dir?name=woof-code/rootfs-skeleton/usr/local/apps/Trash
|
|
Back to top
|
|
 |
zephyr2
Joined: 11 Jan 2013 Posts: 6
|
Posted: Thu 14 Feb 2013, 10:36 Post subject:
|
|
That original empty-list-problem began to wonder me when I was trying to translate Trash in my home language.
Latest Trash I found was version 0.3.3. I changed it so that it could be translated. I am not programmer at all, so changes may look terrible and it's maybe better not to install this at all. However, I have used this translated version for a week now and it should work like original with above fixes (L18L and npierce). I am using Lucid 528, not tested in any other versions.
There is .pot file included, it goes to folder /usr/share/doc/nls/trash.
| Description |
|

Download |
| Filename |
Trash-with-gettext.pet |
| Filesize |
24.27 KB |
| Downloaded |
47 Time(s) |
|
|
Back to top
|
|
 |
L18L
Joined: 19 Jun 2010 Posts: 1711 Location: Burghaslach, Germany
|
Posted: Thu 14 Feb 2013, 15:37 Post subject:
Trash Subject description: internationalized by zephyr2 |
|
| zephyr2 wrote: | | ... I changed it so that it could be translated. ... |
... and I have been using it to make a translation to German.
Just 2 notes:
1,
installing the pet was no good idea for me because my German AppInfo.xml was gone.
2,
trash.pot is NOT necessary because momanager can create it
I attach (just for convenience of everybody) /usr/local/apps/Trash/AppRun
internationalized by zephyr2 (version 0.4 )
----
edited 2013-02-15 10:30 GMT+1
Attachment deleted
BarryK has fixed it in woof, see (and download from)
http://bkhome.org/blog2/?viewDetailed=00125
|
|
Back to top
|
|
 |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|