-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit.basicenv
53 lines (45 loc) · 1.85 KB
/
git.basicenv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/env bash
#
# Copyright (c) Roberto A. Foglietta, 2023
#
# Authors:
# Roberto A. Foglietta <roberto.foglietta@gmail.com>
#
# SPDX-License-Identifier: GPLv3
#
#set -x && resetx="set +x" # RAF: source, paired with set +x at the end of file
set -u # RAF: only for devel, comment in main
if [ ${GFRELOAD:-0} -eq 0 ]; then
echo "${BASH_SOURCE[0]##*/} not reloaded, try again with 'GFRELOAD=1 source'"
return 1
fi
trap 'echo -e "\n'${ERROR:-ERROR}': in '${BASH_SOURCE[0]##*/}\
' at line ${LINENO} occured, try again with set -x\n" >&2' ERR
###############################################################################
if [ ${GITSHLVL:-0} -lt 1 ]; then
# RAF: restricted shell cannot redirect to file but it is fine
# to redirect to a open file descriptor towards /dev/null
# So, also exec could fail but in gitshell &3 is just open
exec 3>/dev/null || return $?
echo "Loading ${BASH_SOURCE[0]##*/} into current bash enviroment"
SRC_FILE=${SRC_FILE:-${gfreload_pathname:-}}
SRC_FILE=${SRC_FILE:-$(readlink -f ${BASH_SOURCE[0]})}
export gfrefdir_pathdir="${SRC_FILE%/*}"
export gfbasicenv_pathname="${gfrefdir_pathdir}/git.basicenv"
export gfunctions_pathname="${gfrefdir_pathdir}/git.functions"
export gfcolors_pathname="${gfrefdir_pathdir}/colors.shell"
export gitshell_pathname="${gfrefdir_pathdir}/git.shell"
export gfreload_pathname="${gitshell_pathname}"
if ! echo "${PATH}" | egrep -q ${gfrefdir_pathdir}; then
export PATH="${gfrefdir_pathdir}/bin:${PATH}"
fi
export gf_gitshell_rcinit=".gitshrc"
fi
if ! type colors_codes_generation >&3 2>&3; then
GFRELOAD=1 source "${gfcolors_pathname}" || return $?
: #RAF: the line above will be stripped
fi #>&3
###############################################################################
${resetx:-}
trap -- ERR
true