bablokb / pi-boot-switch

Boot-Switcher for Raspberry Pi multiboot systems
GNU General Public License v3.0
23 stars 6 forks source link

Some code-parts not working #1

Closed gneiss15 closed 6 years ago

gneiss15 commented 6 years ago

You use somthing like this (in some places): local currentRoot=$(mount | grep -w / | cut -f1 -d" ") This will not result in the desired result, if "mount" will return a line like: //\/\ on /mnt/\ type cifs .... (That are my mounts of Network storage) In generell I wouldn't use grep with option -w if the search string isn't a word. This will result in an incorrect result if there is a "/" followed by another char that isn't a alphanum or underscore. (here the two // will form a match)

One solution might be: local currentRoot=$(mount | grep " / " | cut -f1 -d" ")

but this is only for this special case, So I would sugest this: local currentRoot=$(mount | sed -n "/\W\/\W/s/(^[^ \t])./\1/p")

This is "smaller/faster", because it use only one external function (sed) instead of grep and cut. And You use this kind of search at other places, too.

bablokb commented 6 years ago

Good point, thanks for pointing this out (and for the solution). Did not think about cifs

bablokb commented 6 years ago

Resolved with commit 86afcbca05400ec3871354f2f3213cd4264cde12