From e9df76b0fbb0b20ed8dffad6c62fe55ec3f159c2 Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Sun, 25 Jul 2021 13:14:39 -0700 Subject: [PATCH] Updated SC2112 (markdown) --- SC2112.md | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/SC2112.md b/SC2112.md index 770ce17..e28ee1e 100644 --- a/SC2112.md +++ b/SC2112.md @@ -1 +1,33 @@ -# 'function' keyword is non-standard. Delete it. \ No newline at end of file +## 'function' keyword is non-standard. Delete it. + +### Problematic code: + +```sh +#!/bin/sh +function hello() { + echo "Hello World" +} +``` + +### Correct code: + +```sh +#!/bin/sh +hello() { + echo "Hello World" +} +``` + +### Rationale: + +`function` is a non-standard keyword that can be used to declare functions in Bash and Ksh. + +In POSIX `sh` and `dash`, a function is instead declared without the `function` keyword as in the correct example. + +### Exceptions: + +None. + +### Related resources: + +* Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc! \ No newline at end of file