From d0ef7a4c3c18eb9a315f2e9ac3490d2b657864bf Mon Sep 17 00:00:00 2001 From: koalaman Date: Sun, 21 Jan 2018 14:24:34 -0800 Subject: [PATCH] Created SC1128 (markdown) --- SC1128.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 SC1128.md diff --git a/SC1128.md b/SC1128.md new file mode 100644 index 0000000..a365d0c --- /dev/null +++ b/SC1128.md @@ -0,0 +1,31 @@ +## The shebang must be on the first line. Delete blanks and move comments. + +### Problematic code: + +```sh +# Copyright 2018 Foobar, All rights reserved +#!/bin/bash +``` + +### Correct code: + +```sh +#!/bin/bash +# Copyright 2018 Foobar, All rights reserved +``` + +### Rationale: + +A shebang only has an effect when it appears as the first line in a script. Specifically, the first two bytes of the file must be `#!`. + +Adding comments, copyright notices or simply an accidental blank line before it will turn a shebang into an ineffectual comment. This means that the script is no longer in charge of its own interpreter, and may fail to run or produce different results depending on the context it's run (e.g. it may work from `bash` but not from `zsh` or via `sudo`). + +Delete any leading blank lines, and move all comments after the shebang. + +### Exceptions: + +None + +### Related resources: + +* Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc! \ No newline at end of file