script: improve scripted-diff check
Print generic warning if script fails and add extensible way to check for non portable commands. Tested on OpenBSD and Gentoo Linux using the command line with OpenBSD version 6.9 and GNU sed version 4.8 (Gentoo). Checked for POSIX compliance on https://www.shellcheck.net/. Fixes #19815 (closed)