mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 11:19:45 +08:00
Created SC2127 (markdown)
49
SC2127.md
Normal file
49
SC2127.md
Normal file
@@ -0,0 +1,49 @@
|
||||
## To use `${ ..; }`, specify `#!/usr/bin/env ksh`.
|
||||
|
||||
(Or "To use cases with `;;&`, specify `#!/usr/bin/env bash`)
|
||||
|
||||
### Problematic code:
|
||||
|
||||
```sh
|
||||
#!/usr/bin/env bash
|
||||
var=${ mycmd; };
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```
|
||||
#!/usr/bin/env ksh
|
||||
case "$1" in
|
||||
foo) echo "Foo!" ;;&
|
||||
f*) echo "F-something at least" ;;
|
||||
esac
|
||||
```
|
||||
|
||||
### Correct code:
|
||||
|
||||
```sh
|
||||
#!/usr/bin/env ksh
|
||||
var=${ mycmd; };
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```
|
||||
#!/usr/bin/env bash
|
||||
case "$1" in
|
||||
foo) echo "Foo!" ;;&
|
||||
f*) echo "F-something at least" ;;
|
||||
esac
|
||||
```
|
||||
|
||||
### Rationale:
|
||||
|
||||
You are using a shell syntax feature not supported by the script's shell. Either rewrite the construct, or switch to a different shell interpreter.
|
||||
|
||||
### Exceptions:
|
||||
|
||||
None
|
||||
|
||||
### Related resources:
|
||||
|
||||
* Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!
|
Reference in New Issue
Block a user