-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetfor-shell-toggle-tracing
More file actions
68 lines (58 loc) · 1.75 KB
/
setfor-shell-toggle-tracing
File metadata and controls
68 lines (58 loc) · 1.75 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Sourced script: setfor-shell-toggle-tracing -*- mode: sh; -*-
#
# Purpose : Toggle tracing of shell configuration file sourcing.
# Created : Tuesday, March 26 2024.
# Author : Pierre Rouleau <prouleau001@gmail.com>
# Time-stamp: <2024-05-27 14:58:16 EDT, updated by Pierre Rouleau>
# ----------------------------------------------------------------------------
# Module Description
# ------------------
#
# Toggle printing the sourcing of shell configuration file.
# This tracing helps show which configuration file is used in various
# situations.
# ----------------------------------------------------------------------------
# Code
# ----
#
#
if [[ -n "$(jobs)" ]]; then
# Don't allow re-starting zsh when there are running jobs
# inside the shell. The exec zsh might kill them if they
# were not detached. Warn the user and quit.
echo "Unfinished jobs running. Terminate them first!"
return 1
fi
if [ -z "$USRHOME_TRACE_SHELL_CONFIG" ]; then
export USRHOME_TRACE_SHELL_CONFIG=1
else
if [ "$USRHOME_TRACE_SHELL_CONFIG" = 0 ]; then
export USRHOME_TRACE_SHELL_CONFIG=1
else
export USRHOME_TRACE_SHELL_CONFIG=0
fi
fi
if [ "$USRHOME_TRACE_SHELL_CONFIG" = 0 ]; then
echo "No longer trace shell configuration sourcing."
else
echo "Now trace shell configuration sourcing."
fi
# Identify running shell
#
# Set USRHOME_SHELL to zsh, bash, ..., or unknown
. "$USRHOME_DIR/ibin/which-shell"
case "$USRHOME_SHELL" in
"zsh")
exec zsh
;;
"bash")
exec bash
;;
*)
echo "USRHOME does not support tracing in '$USRHOME_SHELL' shell."
;;
esac
# ----------------------------------------------------------------------------
# Local Variables:
# sh-shell: sh
# End: