Tiny Core Extensions > TCE Bugs
wbar.tcz bug and fix
GNUser:
Hi Rich. Using echo to strip whitespace is a good idea. Given that it's a shell built-in, it's more efficient than sed (if a bit less explicit). I think both solutions are good, but slightly prefer the sed route just because it's more explicit and not significantly more expensive. Juanito can decide. Patch using echo would look like this:
--- 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=$(echo $(awk 'BEGIN{FS = "="}$1=="X-FullPathIcon"{print $2}' "$FREEDESK"))
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 ---
This trick...
--- Code: ---echo "$(cat FileName | awk '$1=$1')" > FileName
--- End code ---
...is really nice and would would also solve the problem. But maybe rewriting .desktop files or creating temporary whitespace-stripped versions of .desktop files would be overkill? Your call, Juanito. If we go that route, we can eliminate the rtrim function from the script.
patrikg:
Sorry for interrupt the thread with my thoughts.
What happens if the user have installed bash, is it the same behavior with bash.
I know some times the /bin/sh is linked to /bin/bash when installing bash.
gadget42:
am also thinking about any/all "what-ifs" and while poking around the webs stumbled across this, which may or may-not be of any help to anyone/someone
did notice one comment regarding _not_using_ "awk '$1=$1'"(added the double-quotes even though it probably wasn't necessary)
https://unix.stackexchange.com/questions/102008/how-do-i-trim-leading-and-trailing-whitespace-from-each-line-of-some-output
also further thinking:
can the final _thing_ at the end of that string be _anything_other_than_ whitespace, and not cause this issue?
(example: "X-FullPathIcon=/usr/local/share/pixmaps/foo.pngl")
(in the above example the additional _thing_ is a lower-case L)
additionally, is this commentary of any value?
https://www.linuxjournal.com/content/normalizing-filenames-and-data-using-bash-string-variable-manipulations
the above commentary also references:
https://www.asciitable.com/
20241030-0324am-cdt-usa-modified: added an addtional comment and url
GNUser:
--- Quote from: patrikg on October 30, 2024, 03:43:11 AM ---What happens if the user have installed bash ... I know some times the /bin/sh is linked to /bin/bash when installing bash.
--- End quote ---
When I patch this I'll change the shebang to #!/bin/busybox ash
This way, we get the shell we expect regardless of where /bin/sh is pointing.
I can let the thread simmer for as long as needed. Rich's idea of removing leading whitespace, trailing whitespace, and blank lines before parsing the .desktop file is very tempting. I'm shy about making big changes to TCL scripts but would be happy with this solution if consensus goes that way. If you guys opt for this route, let me know if you'd prefer rewriting the .desktop files in-place or creating a temporary "working copy" of the .desktop file.
GNUser:
--- Quote from: gadget42 on October 30, 2024, 04:21:30 AM ---also further thinking:
can the final _thing_ at the end of that string be _anything_other_than_ whitespace, and not cause this issue?
(example: "X-FullPathIcon=/usr/local/share/pixmaps/foo.pngl")
(in the above example the additional _thing_ is a lower-case L)
--- End quote ---
wbar icon not showing up because the extension maintainer misspelled something in the .desktop file would be expected, not a surprise/bug in wbar_update.sh. I favor just making sure wbar_update.sh does the expected thing when the .desktop file looks reasonable.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version