Created SC2279 (markdown)

Vidar Holen
2020-12-30 20:13:03 -08:00
parent 55380b7066
commit 8acff16a40

26
SC2279.md Normal file

@@ -0,0 +1,26 @@
## $0 can't be assigned in Dash. This becomes a command name.
### Problematic code:
```sh
#!/bin/dash
$0=myname
```
### Correct code:
`$0` can not be changed in Dash.
### Rationale:
You appear to be trying to assign a new value to `$0` in Dash.
Dash does not support this. Write around it, or switch to Bash.
### Exceptions:
If you instead wanted to compare the value of `$0`, use a comparison like `[ "$0" = "myname" ]`.
### Related resources:
* Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!