Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
dmalan committed Oct 5, 2024
1 parent be19810 commit 8b8ae78
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion etc/profile.d/cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ if [ `id -u` -ne 0 ]; then
# Valgrind
export VALGRIND_OPTS="--memcheck:leak-check=full --memcheck:show-leak-kinds=all --memcheck:track-origins=yes"

## TODO: Start help50 if enabled
# Start help50 if enabled
if help50 is-enabled > /dev/null; then
help50 start
fi
Expand Down
9 changes: 7 additions & 2 deletions etc/profile.d/help50.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,15 @@ function _help50() {
elif [[ $status -ne 0 ]]; then # If helpless
_helpless "$typescript"
fi
else
_helped
fi

# Truncate typescript
truncate -s 0 $HELP50
}

function _question() {
function _rhetorical() {
_alert "That was a rhetorical question. <3"
}

Expand All @@ -108,14 +110,17 @@ if ! type _helpful >/dev/null 2>&1; then

# Intercept accidental invocation of `yes` and `n`, which are actual programs
for name in n no y yes; do
alias $name=_question
alias $name=_rhetocial
done

# Output help
local output=$(_ansi "$1")
_alert "$output"
}
fi
if ! type _helped >/dev/null 2>&1; then
function _helped() { :; } # Silent
fi
if ! type _helpless >/dev/null 2>&1; then
function _helpless() { :; } # Silent
fi
Expand Down
15 changes: 14 additions & 1 deletion opt/cs50/bin/help50
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ function _start() {
fi
}

function _status() {
if [[ -n "$HELP50" ]]; then
echo started
return 0
else
echo stopped
return 1
fi
}

function _stop() {

# If not helping
Expand Down Expand Up @@ -84,11 +94,14 @@ case "$1" in
start)
_start
;;
status)
_status
;;
stop)
_stop
;;
*)
echo "Usage: $0 [disable|enable|is-enabled|start|stop]"
echo "Usage: $0 [disable|enable|is-enabled|start|status|stop]"
exit 1
;;
esac

0 comments on commit 8b8ae78

Please sign in to comment.