A better fix for space in HTML filename
The fix was reported here:
https://bkhome.org/news/202602/fix-open-html-filename-with-space-char.html
So /usr/local/bin/defaultbrowser became this:
#!/bin/sh
P="$(echo -n "$1" | sed -e 's/ /%20/g')"
exec chromium "${P}"
...that works when click on a HTML file in ROX-Filer, as rox only passes a single parameter, $1.
However, 'defaultbrowser' is supposed to be generic, able to handle multiple passed parameters, $1 $2 $3 etc.
I have devised another method:
#!/bin/sh
set -- ${1// /%20} ${2// /%20} ${3// /%20} ${4// /%20}
exec chromium ${@}
...what that does is replace space characters from each passed parameter. I am only doing that up to $4
The rationale is that only one of those $1 to $4 will be the
actual HTML filename, and applying the space-char replacement on
the others won't do anything.
EDIT 2026-02-11:
Note that could have just done this:
#!/bin/sh
exec chromium ${1// /%20} ${2// /%20} ${3// /%20} ${4// /%20}
However, there are scripts that read /usr/local/bin/defaultbrowser and edit it and expect the exec line to be of the format "exec chromium $@"
I need to look at this more carefully. A quick check of the PET package "defaults chooser"; it edits the default* files with this:
echo "#!/bin/sh" > "$newroot/usr/local/bin/default$TYPE"
echo "exec $P \"\$@\"" >> "$newroot/usr/local/bin/default$TYPE"
...not good, that's going back to the old behaviour, expecting a single passed parameter only.
The defaults-chooser PET is ancient, originally written by sc0ttman circa 2010, latter worked on by shinobar, rerwin and myself.
There are some other scripts that edit
default* files by only modifying the "exec" line and leave
whatever is before as-is.
Putting this on the to-do list for further
investigation.
EDIT 2026-02-13:
Decided to keep it simple, treat parameter passed to
/usr/local/bin/default* as just one parameter, the file to be
opened. This is how it has been traditionally in Puppy; trying
to get fancy is too difficult.
The Default Application Chooser app uses this single-parameter approach, and I have fixed it:
https://bkhome.org/news/202602/default-applications-chooser-fixes.html
...it sets /usr/local/bin/defaultbrowser like this:
#!/bin/sh
exec chromium "${1// /%20}"
And all the others as, for example, defaulttexteditor:
#!/bin/sh
exec geany "${@}"
Tags: easy