From 8b8ae7830a294b6d337f1e7b9318ac5cb8789f54 Mon Sep 17 00:00:00 2001 From: "David J. Malan" Date: Sat, 5 Oct 2024 19:50:15 -0400 Subject: [PATCH] WIP --- etc/profile.d/cli.sh | 2 +- etc/profile.d/help50.sh | 9 +++++++-- opt/cs50/bin/help50 | 15 ++++++++++++++- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/etc/profile.d/cli.sh b/etc/profile.d/cli.sh index d321990..9727517 100644 --- a/etc/profile.d/cli.sh +++ b/etc/profile.d/cli.sh @@ -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 diff --git a/etc/profile.d/help50.sh b/etc/profile.d/help50.sh index 65a63e5..6e801be 100644 --- a/etc/profile.d/help50.sh +++ b/etc/profile.d/help50.sh @@ -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" } @@ -108,7 +110,7 @@ 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 @@ -116,6 +118,9 @@ if ! type _helpful >/dev/null 2>&1; then _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 diff --git a/opt/cs50/bin/help50 b/opt/cs50/bin/help50 index f6ca0fc..7b88dc5 100755 --- a/opt/cs50/bin/help50 +++ b/opt/cs50/bin/help50 @@ -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 @@ -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