diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2016-08-21 20:44:39 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2016-08-21 20:44:39 +1200 |
commit | 80076cd9ddfc5dae907ac10f3010925f181b028e (patch) | |
tree | fbc7c4f4050534422bdda0bd0b0e71598f5a000d /sh/profile.d | |
parent | Cache --quiet option for bc(1) in flag file (diff) | |
download | dotfiles-80076cd9ddfc5dae907ac10f3010925f181b028e.tar.gz dotfiles-80076cd9ddfc5dae907ac10f3010925f181b028e.zip |
Restructure ed() to test,cache features on login
Diffstat (limited to 'sh/profile.d')
-rw-r--r-- | sh/profile.d/ed.sh | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/sh/profile.d/ed.sh b/sh/profile.d/ed.sh new file mode 100644 index 00000000..abbd75c5 --- /dev/null +++ b/sh/profile.d/ed.sh @@ -0,0 +1,22 @@ +# Test that we have metadata about what options this system's ed(1) supports, +# and try to create it if not +( + # Create a directory to hold metadata about ed + ecd=$HOME/.cache/ed + if ! [ -d "$ecd" ] ; then + mkdir -p -- "$ecd" || exit + fi + + # Write ed(1)'s --help output to a file, even if it's empty + if ! [ -f "$ecd"/help ] ; then + ed --help </dev/null >"$ecd"/help 2>/dev/null || exit + + # Iterate through some useful options and create files to show they're + # available + set -- verbose + for opt ; do + grep -q -- --"$opt" "$ecd"/help || continue + touch -- "$ecd"/"$opt" || exit + done + fi +) |