Closed hnakamur closed 4 years ago
First of all, thanks for creating and sharing a great script to run systemd!
I noticed https://github.com/DamionGans/ubuntu-wsl2-systemd-script/commit/bb2822c776512345aa597bab9e51d04a4c346239 is somewhat avoiding false positive but not perfect (ex: ^root matches rootfoo).
Another solution would be adding colon after $SUDO_USER and adding BEGIN for settings FS like below:
$ SUDO_USER=root; USER_HOME="$(getent passwd | awk 'BEGIN { FS=":" } /^'"$SUDO_USER"':/ {print $6}')"; echo $USER_HOME /root
However I think this is clearer.
$ SUDO_USER=root; USER_HOME="$(getent passwd | awk -F: '$1=="'"$SUDO_USER"'" {print $6}')"; echo $USER_HOME /root
Sharp eye! Thanks for your contributions!
First of all, thanks for creating and sharing a great script to run systemd!
I noticed https://github.com/DamionGans/ubuntu-wsl2-systemd-script/commit/bb2822c776512345aa597bab9e51d04a4c346239 is somewhat avoiding false positive but not perfect (ex: ^root matches rootfoo).
Another solution would be adding colon after $SUDO_USER and adding BEGIN for settings FS like below:
However I think this is clearer.