krytarik | Eickmeyer: Regarding your latest -default-settings commit, while amending the commands for testing here due to not having any lowlatency kernels installed.. '_lowLatencyKernels=$(ls /boot/vmlinuz-*); _lowLatencyArray=("${_lowLatencyKernels[@]}"); echo "${_lowLatencyArray[-1]}"' outputs "/boot/vmlinuz-5.15.0-2-amd64" and "/boot/vmlinuz-5.15.0-3-amd64" here, while just ... | 17:48 |
---|---|---|
krytarik | ... '_lowLatencyKernels=(/boot/vmlinuz-*); echo "${_lowLatencyKernels[-1]}"' correctly outputs "/boot/vmlinuz-5.15.0-3-amd64" - also you wrote "lastest" in the comment. XD | 17:48 |
Eickmeyer | krytarik: Ooops | 17:49 |
Eickmeyer | krytarik: No? It uses ls /boot/vmlinuz-*-lowlatency | 17:50 |
Eickmeyer | back later | 17:50 |
krytarik | The point being you can just skip 'ls' here and put the file paths in an array directly. | 17:51 |
krytarik | And due to the quoting you are doing in the middle step currently, the whole 'ls' output ends up as a single element in the array. | 17:54 |
krytarik | Which also makes the result completely invalid as an argument to the 'touch' command, because it contains a newline character in between those two file paths as in my case. | 17:58 |
krytarik | ls: cannot access '/boot/vmlinuz-5.15.0-2-amd64'$'\n''/boot/vmlinuz-5.15.0-3-amd64': No such file or directory -- like this, while just using 'ls' for testing here of course. | 18:01 |
Eickmeyer | krytarik: I understand I could avoid LS, but I use shellcheck for best practices and it says that's not a good idea. | 18:37 |
Eickmeyer | Either way, removed the quote which should fix the problem. BUT, I will not remove ls. | 18:38 |
krytarik | Interesting that shellcheck differs there on what's otherwise pretty widely known as bad practice.. :3 | 18:42 |
Eickmeyer | Everyone has different coding styles. :P | 18:46 |
krytarik | I mean a glob like "/boot/vmlinuz-*-lowlatency" on its own already gets expanded to any paths that actually exist, and throwing in a command to list them so the output can be parsed back into the bare paths just makes things unnecessarily inefficient and more error-prone.. | 18:53 |
krytarik | https://stackoverflow.com/questions/10981439/reading-filenames-into-an-array - example commentary on this I've just found. | 18:55 |
Eickmeyer | Very weird that shellcheck doesn't recognize that. | 18:57 |
Eickmeyer | krytarik: I did your thing, it works, pushed. | 22:05 |
Eickmeyer | And shellcheck liked it this time. | 22:05 |
krytarik | Huh.. | 22:07 |
Eickmeyer | Yeah, before I was leaving a $ before the ( which caused it to freak. | 22:11 |
Eickmeyer | So, mea culpa. | 22:11 |
krytarik | Ah yeah, that makes sense then! | 22:12 |
Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!