Warning script from Starred sidebar

I had a problem With Nautilus Starred file:
If I run a script.sh from sidebar/Starred the working directory is/home/user and not the directory of the script, as a symbolic link.

My script delete unwanted file in his own directory, I used it many time without problem from his location, but launched from sidebar/Starred, it deleted all my /home/user.
Fortunately I recently made a backup. I corrected my script, now I use $(dirname -- "$(readlink -f – "$0")";)"

Perhaps there is a way to avoid this risk.

In Ubuntu 24.04/24.10, can you confirm it same in other OS?

It seems that the NAUTILUS_SCRIPT_SELECTED_FILE_PATHS is indeed empty when selecting items in recent. This specific issue with recents can be fixed, but as a general rule, files cannot be guaranteed to have a local path. Also, never delete files using variables in scripts without doing sanity checks.

1 Like