all repos — dotfiles @ 3961eb7bd8f412b12dfe229d93cf3f597f396989

personal dotfiles

clean_local_ssh: fix behaviour
la-ninpre leobrekalini@gmail.com
Thu, 02 Sep 2021 13:14:44 +0300
commit

3961eb7bd8f412b12dfe229d93cf3f597f396989

parent

cc9dfd76fa96d7caa821c661b9c526923f47e93f

1 files changed, 6 insertions(+), 3 deletions(-)

jump to
M bin/.local/bin/clean_local_sshbin/.local/bin/clean_local_ssh

@@ -2,14 +2,17 @@ #!/bin/sh -e

_known_hosts="$HOME/.ssh/known_hosts" -grep localhost "$_known_hosts" +grep localhost "$_known_hosts" || { + echo "no localhost entries" && exit 0 +} printf "remove these entries? [y/N] " read -r REMOVE case "$REMOVE" in - [Y|y]) - grep -v localhost "$_known_hosts" | tee "$_known_hosts.new" + [Yy]) + grep -v localhost "$_known_hosts" > "$_known_hosts.new" mv "$_known_hosts.new" "$_known_hosts" + exit 0 ;; *) exit 1