aboutsummaryrefslogtreecommitdiff
path: root/sh/shrc.d/bc.sh
diff options
context:
space:
mode:
Diffstat (limited to 'sh/shrc.d/bc.sh')
-rw-r--r--sh/shrc.d/bc.sh15
1 files changed, 11 insertions, 4 deletions
diff --git a/sh/shrc.d/bc.sh b/sh/shrc.d/bc.sh
index 643678ac..41331ff9 100644
--- a/sh/shrc.d/bc.sh
+++ b/sh/shrc.d/bc.sh
@@ -1,7 +1,14 @@
-# This function is only applicable if bc(1) has the non-POSIX -q option
-command bc -q </dev/null >&0 2>&0 || return
+# Our ~/.profile should already have made a directory with the supported
+# options for us; if not, we won't be wrapping bc(1) with a function at all
+[ -d "$HOME"/.cache/bc ] || return
-# Don't print the bc(1) welcome message
+# Define function proper
bc() {
- command bc -q "$@"
+
+ # Add --quiet to stop the annoying welcome banner
+ [ -e "$HOME"/.cache/bc/quiet ] &&
+ set -- --quiet "$@"
+
+ # Run bc(1) with the concluded arguments
+ command bc "$@"
}