heads
heads copied to clipboard
WIP: Shellcheck script files in initrd
- [X] Shell scripts without a file extension in
/initrdrenamed with.shfor consistency and simplifying shellcheck glob search. - [X] Any
#!/bin/ashshebangs are changed to#!/bin/shas shellcheck does not haveashsupport. - [ ] Rewrite commands to be generic POSIX shell If possible, add shelllcheck exception where it is not.
- [ ] Use relative source paths to validate imported variables and functions.
- [ ] Manually test changes
Resolve shellcheck errors:
- [x] SC1001
- [x] SC1009
- [x] SC1072
- [x] SC1073
- [x] SC1078
- [x] SC1079
- [x] SC1083
- [ ] SC1091
- [x] SC2002
- [x] SC2004
- [x] SC2005
- [x] SC2006
- [x] SC2012
- [x] SC2013
- [x] SC2015
- [x] SC2016
- [x] SC2030
- [x] SC2031
- [x] SC2034
- [ ] SC2039
- [x] SC2044
- [x] SC2046
- [x] SC2086
- [x] SC2091
- [x] SC2093
- [ ] SC2094
- [x] SC2104
- [x] SC2116
- [x] SC2119
- [x] SC2120
- [x] SC2124
- [x] SC2154
- [x] SC2155
- [x] SC2157
- [x] SC2160
- [x] SC2162
- [x] SC2166
- [x] SC2181
- [x] SC2188
- [x] SC2210
- [x] SC2216
- [x] SC2220
- [x] SC2231
- [x] SC2236
- [x] SC2242
To investigate:
- [ ]
/initrd/sbin/config-dhcp.sh- variables not defined, does not seem to be functional.
@Thrilleratplay Waoooow!!!! Awesome initiative!!!!
* `/initrd/sbin/config-dhcp.sh` - variables not defined, does not seem to be functional.
Is called from https://github.com/osresearch/heads/blob/624faa1a9d9c7794927757ff49fbb567d6d031fb/config/busybox.config#L954 while I implemented DHCP configuration here.
@tlaurion Thank you for pointing out where it is referenced. I am going to make changes to /sbin/config-dhcp.sh separately and should read up on how busybox interacts with DHCP scripts. Likely for now, I will just make an exception for the undeclared variables that are used in the script.
Closing this in favor of #872
This is preferred approach over #872 (now closed).
The logic behind this is that bash is not fully supported under busybox, even as of today, where having scripts declaring bash interpreter vs ash will be misleading.
What changed (I think) since thn is that ASH is supported from shellcheck. This is actually DASH compliant, and we could get around shellcheck error SC2187 by doing either:
#!/bin/ash
# shellcheck shell=dash
As reported there, having shellcheck check for dash vs ash will report errors saying that echo -e is not supported under dash (which shellcheck supports). We will have to mute those errors as well, since we use echo -e under Heads.
So the workaround would be something in the lines of (until either busybox is fully supporting bash or shellcheck is fully supporting ash):
#!/bin/ash
# shellcheck shell=ash #we foce support for ash even if shellcheck complains it only supports dash
# shellcheck disable=SC3036 #echo -e is supported under ash but not dash
As you see, nothing perfect again.
The desired path is actually to have posix compliant scripts (where shellcheck currently complains for coding standards, but the scripts are compliant as of now).
Discussion happening over #885. Cross-linking from there to here.