From 65211115a003d5efbd75b4adfe84d93f49b6c9cf Mon Sep 17 00:00:00 2001 From: toogley Date: Sun, 20 Mar 2016 20:15:27 +0100 Subject: [PATCH] make default settings for bash more reliable see http://redsymbol.net/articles/unofficial-bash-strict-mode/ for explanation why this might be useful. --- UltiSnips/sh.snippets | 4 ++++ snippets/sh.snippets | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/UltiSnips/sh.snippets b/UltiSnips/sh.snippets index 9cc4577..33e5d00 100644 --- a/UltiSnips/sh.snippets +++ b/UltiSnips/sh.snippets @@ -33,6 +33,10 @@ snippet !env "#!/usr/bin/env (!env)" `!p snip.rv = '#!/usr/bin/env ' + getShell() + "\n\n" ` endsnippet +snippet sbash "safe bash options" +`!p snip.rv = '#!/usr/bin/env bash' + "\nset -euo pipefail\nIFS=$'\n\t'" + "\n\n" ` +endsnippet + snippet temp "Tempfile" ${1:TMPFILE}="$(mktemp -t ${2:`!p snip.rv = re.sub(r'[^a-zA-Z]', '_', snip.fn) or "untitled" diff --git a/snippets/sh.snippets b/snippets/sh.snippets index 4d2c62b..e470a2a 100644 --- a/snippets/sh.snippets +++ b/snippets/sh.snippets @@ -5,6 +5,11 @@ snippet #! snippet bash #!/usr/bin/env bash +snippet sbash + #!/usr/bin/env bash + set -euo pipefail + IFS=$'\n\t' + snippet if if [[ ${1:condition} ]]; then ${0:#statements}