diff options
author | ene <ene@sils.li> | 2023-02-19 23:45:08 +0100 |
---|---|---|
committer | ene <ene@sils.li> | 2023-02-19 23:45:08 +0100 |
commit | 508f70b7f66d5da17c8381545f5b67894fcbd576 (patch) | |
tree | e623806384d9f996080c569a98decf756bfec0c6 /bootstrap/install.sh | |
parent | Fix(bootstrap): Allow to run the installer multiple times (diff) | |
download | nixos-config-508f70b7f66d5da17c8381545f5b67894fcbd576.zip |
Fix(bootstrap): Fix nasty grep bug
Diffstat (limited to '')
-rwxr-xr-x | bootstrap/install.sh (renamed from bootstrap/install) | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/bootstrap/install b/bootstrap/install.sh index 81829019..37a5e758 100755 --- a/bootstrap/install +++ b/bootstrap/install.sh @@ -99,9 +99,9 @@ case $result in msg "Great, select a host-config:" hosts=$(mktmp); host=""; - awk -F "." '/nixosConfiguration/{print $2}' "$(tmp 'curl https://git.sils.li/ene/nixos-config/raw/branch/prime/flake.nix')" | awk '{print $1}' > $hosts; + awk -F "." '/nixosConfiguration/{print $2}' "$(tmp 'curl https://git.sils.li/ene/nixos-config/raw/branch/prime/flake.nix 2> /dev/null')" | awk '{print $1}' > $hosts; - while ! grep "$host" "$hosts" > /dev/null && [ "$host" == "" ]; do + while ! grep "$host" "$hosts" > /dev/null || [ "$(printf "%s" "$host" | wc -c)" -eq 0 ]; do i=1; while read -r ho ; do printf "%4s) %s \n" "$i" "$ho"; @@ -110,10 +110,9 @@ case $result in printf "%4s) Exit\n" "q" readp "Enter a option: " host - [ $host = "q" ] && exit 1 - if grep "$host" "$hosts" > /dev/null && [ "$host" != "" ]; then - host=$(awk -v i="$host" '{if (NR==i) {print $0}}' "$hosts"); - else + [ "$host" = "q" ] && exit 1 + host=$(awk -v i="$host" '{if (NR==i) {print $0}}' "$hosts"); + if ! grep "$host" "$hosts" > /dev/null || [ "$(printf "%s" "$host" | wc -c)" -eq 0 ]; then warning "No host selected. Select a host to continue.\n" fi done |