The executable scripts will be always executed in Pantheon Files when clicked, no matter the application set as default for that type of files. (bug report: https://bugs.launchpad.net/pantheon-files/+bug/1669996).
A solution for what is asked (avoiding to start scripts when accidentally clicking them), as suggested in the answer on Nautilus, is to use another file manager which has the desired option when manipulating those scripts.
Creating a run_zenity.sh
with the script from the answer on Zenity
#!/bin/bash
zenity --question --text="Do you wish to run '$1', or display its contents?" \
--ok-label=Run \
--cancel-label=Edit
case $? in
0)pcmanfm "$1"
;;
1)scratch-text-editor $1
;;
esac
and a contract file for that
gedit ~/.local/share/contractor/runoredit-zenity.contract
with a content like
[Contractor Entry]
Name=RUN OR EDIT
Icon=terminal
MimeType=application/x-sh;application/x-executable;
Exec=bash -c '/path/to/the/script/run_zenity.sh %f'
you will get a new context menu in Pantheon Files; but that is not very useful, as it only provides options that are already provided by the Run and Open with entry.

Anyway, that entry opens the Zenity dialog, which works as expected:

The zenity dialog script can be added to a desktop
file (a launcher in ~/.local/share/applications
), and the launcher can be set the default 'application' to be used for all executable scripts in Pantheon Files (so that it shows that dialog and avoid the risk of executing the scripts by accident), but no matter that setting Pantheon File will always execute a file if it is an executable file. On the other hand that works ok for .desktop
files. (See more on that HERE and below for Thunar).
So, considering other file managers:
PCManFM
Beside Nautilus already mentioned, an even lighter File Manager, PCManFM provides this by default.

'Open' will use the default application.
That can be changed in settings

Thunar
Unlike PCManFM, Thunar file manager doesn't seem to have that dialog for executable files, but in Thunar the Zenity script can be made the default application for scripts as indicated, and then, when clicking a script in Thunar the Zenity dialog will appear. For that, create a desktop
file:
gedit ~/.local/share/applications/run-or-edit.desktop
with
[Desktop Entry]
Type=Application
Name=Run or edit
Icon=gedit
Categories=Utility;TextEditor;
MimeType=application/x-sh;application/x-executable;
Exec=bash -c '/path/to/the/script/run_zenity.sh %f'
Then, no matter the file manager, set the new "application" called Run or edit the default for script files under a file's properties.
As said, in Pantheon Files that changes nothing, but in Thunar it will open the Zenity dialog when clicking to open a script.
To be sure the Run or edit app appears in the list when you try to set is as default, you can add these lines
application/x-sh=run-or-edit.desktop
application/x-executable=run-or-edit.desktop
in ~/.local/share/applications/mimeinfo.cache
under [MIME CACHE]
and also in ~/.local/share/applications/mimeapps.list
under [Default Applications]
.
There are a few glitches with that Zenity script: after the dialog is displayed, dismissing it with Esc or the window close button (x) will still open the file in the text editor. (As it is a 'yes or no' dialog, 'no' is the text editor.) To improve that behavior look here.