Avoid assert in kfileitem.cpp

By reloading a document (F5) with unsaved changes, one easily triggers:
ASSERT: "!d->m_url.isEmpty()" in file
/home/krf/devel/src/kdelibs/kio/kio/kfileitem.cpp, line 1662
Make shell scripts portable and stable.

This patch makes provided scripts run on a generic Unix, and not only
on bash-enabled ones. Also, some concepts were changed to more correct
ones.

REVIEW: 119192