Optimise shell detection code (Closes: #1550)

Open username-removed-134837 requested to merge onlyjob/gitlab-ci-multi-runner:shell into master