From 2d392c27d78cce8c7b663a17abbd1c699e997b54 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 21 Aug 2016 17:43:58 +1200 Subject: Cache --quiet option for bc(1) in flag file As done for grep(1) and ls(1); ed(1) is next --- sh/profile.d/bc.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 sh/profile.d/bc.sh (limited to 'sh/profile.d') diff --git a/sh/profile.d/bc.sh b/sh/profile.d/bc.sh new file mode 100644 index 00000000..16200b33 --- /dev/null +++ b/sh/profile.d/bc.sh @@ -0,0 +1,22 @@ +# Test that we have metadata about what options this system's bc(1) supports, +# and try to create it if not +( + # Create a directory to hold metadata about bc + bcd=$HOME/.cache/bc + if ! [ -d "$bcd" ] ; then + mkdir -p -- "$bcd" || exit + fi + + # Write bc(1)'s --help output to a file, even if it's empty + if ! [ -f "$bcd"/help ] ; then + bc --help "$bcd"/help 2>/dev/null || exit + + # Iterate through some useful options and create files to show they're + # available + set -- quiet + for opt ; do + grep -q -- --"$opt" "$bcd"/help || continue + touch -- "$bcd"/"$opt" || exit + done + fi +) -- cgit v1.2.3