From 7e03a9f5ae0904dcbb36295e747e7bcc0d41c3ca Mon Sep 17 00:00:00 2001 From: koalaman Date: Mon, 10 Jul 2017 23:23:12 -0700 Subject: [PATCH] Revert a89b80409e1050fcdc4ca8772acfa2e52853cf43...33087384aec8dcc93f0dca781770f579d768f6f9 on Template --- Template.md | 33 ++++----------------------------- 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/Template.md b/Template.md index 0bb55c3..8491d0b 100644 --- a/Template.md +++ b/Template.md @@ -3,43 +3,18 @@ ### Problematic code: ```sh -#!/bin/sh -myfunction - -myfunction() { - echo "Hello World" -} +# Simple example of problematic code ``` ### Correct code: ```sh -#!/bin/sh -myfunction() { - echo "Hello World" -} -myfunction +# Simple example of above code, only fixed ``` - ### Rationale: -You are calling a function that you are defining later in the file. The function definition must come first. - -Function definitions are much like variable assignments, and define a name at the point the definition is "executed". This is why they must happen before their first use. - -This is especially apparent when defining functions conditionally: - -``` -case "$(uname -s)" in - Linux) hi() { echo "Hello from Linux"; } ;; - Darwin) hi() { echo "Hello from macOS"; } ;; - *) hi() { echo "Hello from something else"; } ;; -esac - -hi -``` - +(An explanation of why the code is problematic and how the correct code is an improvement) ### Exceptions: -None. \ No newline at end of file +(Cases where the user may choose to ignore this warning, if any.) \ No newline at end of file