From 386ec3bb9a0a35be10431d3da9fa21a1d9bc29e2 Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Thu, 17 Oct 2019 11:29:07 -0400 Subject: [PATCH] fix sl ssh detection --- .bashrc | 23 ++++++++++++++++------- brc2 | 6 ++++-- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/.bashrc b/.bashrc index 6780da6..c27af43 100644 --- a/.bashrc +++ b/.bashrc @@ -55,17 +55,26 @@ else # this file, and we don't want to do that and cause an infinite # loop. fi - _x=$(readlink -f ${BASH_SOURCE[0]}) - _x=${_x%/*}/brc - if [[ -r $_x ]]; then + _tmp=$(readlink -f ${BASH_SOURCE[0]}) + _tmp=${_tmp%/*} + _tmp2=$_tmp/brc + if [[ -s $_tmp2 ]]; then # shellcheck source=./brc - source $_x + source $_tmp2 fi # brc2 is for things i dont necessarily want on every system - _x=${_x%/*}/brc2 - if [[ -r $_x ]]; then + _tmp2=$_tmp/brc2 + if [[ -s $_tmp2 ]]; then # shellcheck source=./brc2 - source $_x + source $_tmp2 + else + # This check is for when running the sl() command, + # and the remote host got its type misidentified. + _tmp2=$_tmp/../brc2 + if [[ -s $_tmp2 ]]; then + # shellcheck source=./brc2 + source $_tmp2 + fi fi fi # ensure no bad programs appending to this file will have an affect diff --git a/brc2 b/brc2 index 20780fa..7c33bea 100644 --- a/brc2 +++ b/brc2 @@ -817,13 +817,15 @@ sl() { info_date=${tmp::11} type=${info_date: -1} info_date=${info_date::10} + info_sec=$(date -d @$info_date +%s) # debug #e $(( $(stat -c%Y /b/ds/brc) - $(date -d @$info_date +%s) )) - if (( $(stat -c%Y /b/ds/brc) > $(date -d @$info_date +%s) )); then + if (( $(stat -c%Y /b/ds/brc) > info_sec || $(stat -c%Y /b/ds/.bashrc) > info_sec )); then old=true fi else - tmp=$(command ssh -t "${args[@]}" "$remote" "if test -e /p/sshinfo; then echo yes; fi") || return + # use this weird yes thing to ensure we know ssh succeeded + tmp=$(command ssh "${args[@]}" "$remote" "if test -e /p/sshinfo; then echo yes; fi") || return if [[ $tmp == yes ]]; then type=a else -- 2.30.2