Is your feature request related to a problem? Please describe.
Running shellcheck on battery.sh results in a bunch of errors. This should be looked into.
Describe the solution you'd like
Running shellcheck in CI could result in better code readability and prevent possible bugs from appearing in the future
Additional context
Since this entire program relies on the CLI (if I understand it correctly), possibly preventing any bugs is always a good thing.
Shellcheck output
```bash
In battery.sh line 29:
mkdir -p $configfolder
^-----------^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
mkdir -p "$configfolder"
In battery.sh line 32:
touch $logfile
^------^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
touch "$logfile"
In battery.sh line 38:
tail -n 100 $logfile >$logfile
^------^ SC2086 (info): Double quote to prevent globbing and word splitting.
^------^ SC2094 (info): Make sure not to read and write the same file in the same pipeline.
^------^ SC2086 (info): Double quote to prevent globbing and word splitting.
^------^ SC2094 (info): Make sure not to read and write the same file in the same pipeline.
Did you mean:
tail -n 100 "$logfile" >"$logfile"
In battery.sh line 217:
battery_percentage=$(pmset -g batt | tail -n1 | awk '{print $3}' | sed s:\%\;::)
^-- SC1001 (info): This \% will be a regular '%' in this context.
In battery.sh line 227:
maintain_percentage=$(cat $maintain_percentage_tracker_file 2>/dev/null)
^-- SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
maintain_percentage=$(cat "$maintain_percentage_tracker_file" 2>/dev/null)
In battery.sh line 246:
echo -e "$visudoconfig" >$visudo_tmpfile
^-------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
echo -e "$visudoconfig" >"$visudo_tmpfile"
In battery.sh line 249:
if sudo cmp $visudo_file $visudo_tmpfile &>/dev/null; then
^-------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
if sudo cmp $visudo_file "$visudo_tmpfile" &>/dev/null; then
In battery.sh line 265:
if sudo visudo -c -f $visudo_tmpfile &>/dev/null; then
^-------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
if sudo visudo -c -f "$visudo_tmpfile" &>/dev/null; then
In battery.sh line 273:
sudo cp $visudo_tmpfile $visudo_file
^-------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
sudo cp "$visudo_tmpfile" $visudo_file
In battery.sh line 276:
rm $visudo_tmpfile
^-------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
rm "$visudo_tmpfile"
In battery.sh line 285:
sudo visudo -c -f $visudo_tmpfile
^-------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
sudo visudo -c -f "$visudo_tmpfile"
In battery.sh line 296:
read
^--^ SC2162 (info): read without -r will mangle backslashes.
In battery.sh line 312:
read
^--^ SC2162 (info): read without -r will mangle backslashes.
In battery.sh line 325:
read
^--^ SC2162 (info): read without -r will mangle backslashes.
In battery.sh line 441:
maintain_percentage=$(cat $maintain_percentage_tracker_file 2>/dev/null)
^-- SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
maintain_percentage=$(cat "$maintain_percentage_tracker_file" 2>/dev/null)
In battery.sh line 444:
setting=$(echo $maintain_percentage)
^--------------------------^ SC2116 (style): Useless echo? Instead of 'cmd $(echo foo)', just use 'cmd foo'.
^------------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
setting=$(echo "$maintain_percentage")
In battery.sh line 502:
kill $pid &>/dev/null
^--^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
kill "$pid" &>/dev/null
In battery.sh line 507:
rm $pidfile 2>/dev/null
^------^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
rm "$pidfile" 2>/dev/null
In battery.sh line 529:
nohup battery maintain_synchronous $setting $subsetting >>$logfile &
^------^ SC2086 (info): Double quote to prevent globbing and word splitting.
^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.
^------^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
nohup battery maintain_synchronous "$setting" "$subsetting" >>"$logfile" &
In battery.sh line 532:
echo $! >$pidfile
^------^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
echo $! >"$pidfile"
In battery.sh line 537:
echo $setting >$maintain_percentage_tracker_file
^------^ SC2086 (info): Double quote to prevent globbing and word splitting.
^-- SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
echo "$setting" >"$maintain_percentage_tracker_file"
In battery.sh line 552:
if test -f $pidfile; then
^------^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
if test -f "$pidfile"; then
In battery.sh line 553:
maintain_percentage=$(cat $maintain_percentage_tracker_file 2>/dev/null)
^-- SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
maintain_percentage=$(cat "$maintain_percentage_tracker_file" 2>/dev/null)
In battery.sh line 618:
launchctl enable "gui/$(id -u $USER)/com.battery.app"
^---^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
launchctl enable "gui/$(id -u "$USER")/com.battery.app"
In battery.sh line 626:
log "Disabling daemon at gui/$(id -u $USER)/com.battery.app"
^---^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
log "Disabling daemon at gui/$(id -u "$USER")/com.battery.app"
In battery.sh line 627:
launchctl disable "gui/$(id -u $USER)/com.battery.app"
^---^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
launchctl disable "gui/$(id -u "$USER")/com.battery.app"
In battery.sh line 635:
rm $daemon_path 2>/dev/null
^----------^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
rm "$daemon_path" 2>/dev/null
In battery.sh line 646:
tail -n $amount $logfile
^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
^------^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
tail -n "$amount" "$logfile"
In battery.sh line 649:
tail -n $amount "$configfolder/gui.log"
^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
tail -n "$amount" "$configfolder/gui.log"
In battery.sh line 652:
ls -lah $configfolder
^-----------^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
ls -lah "$configfolder"
For more information:
https://www.shellcheck.net/wiki/SC1001 -- This \% will be a regular '%' in ...
https://www.shellcheck.net/wiki/SC2086 -- Double quote to prevent globbing ...
https://www.shellcheck.net/wiki/SC2094 -- Make sure not to read and write t...
```
Is your feature request related to a problem? Please describe. Running shellcheck on
battery.sh
results in a bunch of errors. This should be looked into.Describe the solution you'd like Running shellcheck in CI could result in better code readability and prevent possible bugs from appearing in the future
Additional context Since this entire program relies on the CLI (if I understand it correctly), possibly preventing any bugs is always a good thing.
Shellcheck output
```bash In battery.sh line 29: mkdir -p $configfolder ^-----------^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: mkdir -p "$configfolder" In battery.sh line 32: touch $logfile ^------^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: touch "$logfile" In battery.sh line 38: tail -n 100 $logfile >$logfile ^------^ SC2086 (info): Double quote to prevent globbing and word splitting. ^------^ SC2094 (info): Make sure not to read and write the same file in the same pipeline. ^------^ SC2086 (info): Double quote to prevent globbing and word splitting. ^------^ SC2094 (info): Make sure not to read and write the same file in the same pipeline. Did you mean: tail -n 100 "$logfile" >"$logfile" In battery.sh line 217: battery_percentage=$(pmset -g batt | tail -n1 | awk '{print $3}' | sed s:\%\;::) ^-- SC1001 (info): This \% will be a regular '%' in this context. In battery.sh line 227: maintain_percentage=$(cat $maintain_percentage_tracker_file 2>/dev/null) ^-- SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: maintain_percentage=$(cat "$maintain_percentage_tracker_file" 2>/dev/null) In battery.sh line 246: echo -e "$visudoconfig" >$visudo_tmpfile ^-------------^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: echo -e "$visudoconfig" >"$visudo_tmpfile" In battery.sh line 249: if sudo cmp $visudo_file $visudo_tmpfile &>/dev/null; then ^-------------^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: if sudo cmp $visudo_file "$visudo_tmpfile" &>/dev/null; then In battery.sh line 265: if sudo visudo -c -f $visudo_tmpfile &>/dev/null; then ^-------------^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: if sudo visudo -c -f "$visudo_tmpfile" &>/dev/null; then In battery.sh line 273: sudo cp $visudo_tmpfile $visudo_file ^-------------^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: sudo cp "$visudo_tmpfile" $visudo_file In battery.sh line 276: rm $visudo_tmpfile ^-------------^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: rm "$visudo_tmpfile" In battery.sh line 285: sudo visudo -c -f $visudo_tmpfile ^-------------^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: sudo visudo -c -f "$visudo_tmpfile" In battery.sh line 296: read ^--^ SC2162 (info): read without -r will mangle backslashes. In battery.sh line 312: read ^--^ SC2162 (info): read without -r will mangle backslashes. In battery.sh line 325: read ^--^ SC2162 (info): read without -r will mangle backslashes. In battery.sh line 441: maintain_percentage=$(cat $maintain_percentage_tracker_file 2>/dev/null) ^-- SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: maintain_percentage=$(cat "$maintain_percentage_tracker_file" 2>/dev/null) In battery.sh line 444: setting=$(echo $maintain_percentage) ^--------------------------^ SC2116 (style): Useless echo? Instead of 'cmd $(echo foo)', just use 'cmd foo'. ^------------------^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: setting=$(echo "$maintain_percentage") In battery.sh line 502: kill $pid &>/dev/null ^--^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: kill "$pid" &>/dev/null In battery.sh line 507: rm $pidfile 2>/dev/null ^------^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: rm "$pidfile" 2>/dev/null In battery.sh line 529: nohup battery maintain_synchronous $setting $subsetting >>$logfile & ^------^ SC2086 (info): Double quote to prevent globbing and word splitting. ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting. ^------^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: nohup battery maintain_synchronous "$setting" "$subsetting" >>"$logfile" & In battery.sh line 532: echo $! >$pidfile ^------^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: echo $! >"$pidfile" In battery.sh line 537: echo $setting >$maintain_percentage_tracker_file ^------^ SC2086 (info): Double quote to prevent globbing and word splitting. ^-- SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: echo "$setting" >"$maintain_percentage_tracker_file" In battery.sh line 552: if test -f $pidfile; then ^------^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: if test -f "$pidfile"; then In battery.sh line 553: maintain_percentage=$(cat $maintain_percentage_tracker_file 2>/dev/null) ^-- SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: maintain_percentage=$(cat "$maintain_percentage_tracker_file" 2>/dev/null) In battery.sh line 618: launchctl enable "gui/$(id -u $USER)/com.battery.app" ^---^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: launchctl enable "gui/$(id -u "$USER")/com.battery.app" In battery.sh line 626: log "Disabling daemon at gui/$(id -u $USER)/com.battery.app" ^---^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: log "Disabling daemon at gui/$(id -u "$USER")/com.battery.app" In battery.sh line 627: launchctl disable "gui/$(id -u $USER)/com.battery.app" ^---^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: launchctl disable "gui/$(id -u "$USER")/com.battery.app" In battery.sh line 635: rm $daemon_path 2>/dev/null ^----------^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: rm "$daemon_path" 2>/dev/null In battery.sh line 646: tail -n $amount $logfile ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting. ^------^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: tail -n "$amount" "$logfile" In battery.sh line 649: tail -n $amount "$configfolder/gui.log" ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: tail -n "$amount" "$configfolder/gui.log" In battery.sh line 652: ls -lah $configfolder ^-----------^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: ls -lah "$configfolder" For more information: https://www.shellcheck.net/wiki/SC1001 -- This \% will be a regular '%' in ... https://www.shellcheck.net/wiki/SC2086 -- Double quote to prevent globbing ... https://www.shellcheck.net/wiki/SC2094 -- Make sure not to read and write t... ```