Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use POSIX syntax for fatal function def #697

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Use POSIX syntax for fatal function def #697

wants to merge 1 commit into from

Conversation

cceckman
Copy link

@cceckman cceckman commented Sep 9, 2020

I invoked this script from a /bin/sh script, as ./create-latest-svc.sh, and got:

./create-latest-svc.sh: 43: ./create-latest-svc.sh: Syntax error: "(" unexpected 

The Bash version on this machine is GNU bash, version 5.0.3(1)-release (x86_64-pc-linux-gnu) .

man bash seems to indicate the parentheses are optional, so I'm not sure why it's complaining. The POSIX shell command language (here doesn't keywordize function, but does require parens:

foo() {
  ...
}

While I'm not 100% sure what set of modes Bash has that's causing it to reject the function + parens syntax, removing the bashism does fix it for me. ¯_(ツ)_/¯

I invoked this script from a `/bin/sh` script, as `./create-latest-svc.sh`, and got:

```
./create-latest-svc.sh: 43: ./create-latest-svc.sh: Syntax error: "(" unexpected 
```

The Bash version on this machine is `GNU bash, version 5.0.3(1)-release (x86_64-pc-linux-gnu) `.

`man bash` seems to indicate the parentheses are optional, so I'm not sure why it's complaining. The POSIX shell command language ([here](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_05) doesn't keywordize `function`, but does require parens:

```
foo() {
  ...
}
```

While I'm not 100% sure what set of modes Bash has that's causing it to reject the `function` + parens syntax, removing the bashism and using POSIX syntax should be generally compatible.
Copy link

@zimbatm zimbatm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants