minor bug fix
[distro-setup] / .bashrc
1 #!/bin/bash
2 # Copyright (C) 2019 Ian Kelling
3 # SPDX-License-Identifier: AGPL-3.0-or-later
4
5 # to debug
6 #set -x
7 # redirect output to log file. this doesn't work. todo figure out why
8 #exec 1>>/a/tmp/bashlog
9 #exec 2>>/a/tmp/bashlog
10
11
12 # see comments in brc2 sl() function for background.
13 if [[ $SSH_CONNECTION ]] \
14 && [[ $BRC != t ]]; then
15 return 0
16 else
17
18 # the distinction between login and non-login shells is lame,
19 # get rid of it. note ssh shells normally its login if a command is passed
20 if ! shopt -q login_shell; then
21 if [[ -r /etc/profile ]]; then
22 source /etc/profile
23 fi
24 # note, this is not exactly the same as a login shell, because that
25 # reads ~/.bash_profile or alternative, which usually just sources
26 # this file, and we don't want to do that and cause an infinite
27 # loop.
28 fi
29 _tmp=$(readlink -f ${BASH_SOURCE[0]})
30 _tmp=${_tmp%/*}
31 _tmp2=$_tmp/brc
32 if [[ -s $_tmp2 ]]; then
33 # shellcheck source=./brc
34 source $_tmp2
35 fi
36 # brc2 is for things i dont necessarily want on every system
37 _tmp2=$_tmp/brc2
38 if [[ -s $_tmp2 ]]; then
39 # shellcheck source=./brc2
40 source $_tmp2
41 else
42 # This check is for when running the sl() command,
43 # and the remote host got its type misidentified.
44 _tmp2=$_tmp/../brc2
45 if [[ -s $_tmp2 ]]; then
46 # shellcheck source=./brc2
47 source $_tmp2
48 fi
49 fi
50 fi
51 # ensure no bad programs appending to this file will have an affect
52 return 0