Tiny Core Extensions > TCE Bugs

wbar.tcz bug and fix

(1/6) > >>

GNUser:
Hello, TCL developers. I found a minor bug in wbar_update.sh (part of wbar.tcz): No wbar icon shows up for extension foo.tcz if /usr/local/share/applications/foo.desktop has any trailing whitespace in the "X-FullPathIcon=" line.

In other words, if /usr/local/share/applications/foo.desktop has a line like "X-FullPathIcon=/usr/local/share/pixmaps/foo.png " then no wbar icon shows up because of that little space at the end.

The fix is the attached patch, which I also pasted below.


--- Code: ------ a/wbar_update.sh
+++ b/wbar_update.sh
@@ -19,7 +19,7 @@
     test = match(exec,"%")
     if ( test ) exec = substr(exec,0,test-1)
   } else if ( $1 == "X-FullPathIcon" ) {
-    icon = $2
+    icon = rtrim($2)
   } else if ( $1 == "Terminal" ) {
     terminal = $2
   }
@@ -71,7 +71,7 @@
 #
 FREEDESK=/usr/local/share/applications/"$APPNAME".desktop
 if [ -e "$FREEDESK" ]; then
-   ICONCHECK="$(awk 'BEGIN{FS = "="}$1=="X-FullPathIcon"{print $2}' "$FREEDESK")"
+   ICONCHECK="$(awk 'BEGIN{FS = "="}$1=="X-FullPathIcon"{print $2}' "$FREEDESK" | busybox sed -r 's/[ \t]+$//')"
    NAMECHECK="$(awk 'BEGIN{FS = "="}$1=="Name"{print $2; exit 0}' "$FREEDESK")"
    if grep -qw "^t: *${NAMECHECK// /}$" "${TCEDIR}"/xwbar.lst 2>/dev/null; then exit 0; fi
    TARGET="$APPNAME".img

--- End code ---

GNUser:
P.S. This issue came up because an extension contributor contacted me for help, wondering why his extension's wbar icon wasn't showing up. It took us over 24 hours of back-and-forth before I finally realized what was causing his problem. I only realized the problem had to do with whitespace in the .desktop file because I had excluded everything else.

GNUser:
Hi Juanito. You are the maintainer of wbar.tcz. Would you like me to submit wbar.tcz with the above patch?

Rich:
Hi GNUser
A couple of other ways of dealing with whitespace.

Remove leading and trailing whitespace from a variable:

--- Code: ---Var2="$(echo "$Var1" | awk '$1=$1')"
--- End code ---

Here's something I noticed under ash:

--- Code: ---tc@E310:~$ Var1="  Space me  "
tc@E310:~$ echo "$Var1"
  Space me 
tc@E310:~$ echo $Var1
Space me
--- End code ---
Echoing $Var1 with quotes preserved leading and trailing whitespace.
Echoing $Var1 without quotes stripped leading and trailing whitespace.

So you can do this using ash. I don't know if other shells behave the same way.

--- Code: ---tc@E310:~$ Var1=$(echo $Var1)
tc@E310:~$ echo "$Var1"
Space me
--- End code ---

This will strip leading and trailing whitespace from all lines in a file.
It will also remove all blank lines:

--- Code: ---echo "$(cat FileName | awk '$1=$1')" > FileName
--- End code ---

Juanito:

--- Quote from: GNUser on October 29, 2024, 04:14:23 PM ---Hi Juanito. You are the maintainer of wbar.tcz. Would you like me to submit wbar.tcz with the above patch?

--- End quote ---


I was waiting for a couple of days to see if there were any comments ;)

Navigation

[0] Message Index

[#] Next page

Go to full version