aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2014-10-16 14:09:40 +1300
committerTom Ryder <tom@sanctum.geek.nz>2014-10-16 14:09:40 +1300
commit36320a75d1306bf113b618243765557d56d12960 (patch)
treed998b06a100db1194f3d0a14d646eda9624ac29d /bin
parentDefer expansion until bell alias use (diff)
downloaddotfiles-36320a75d1306bf113b618243765557d56d12960.tar.gz
dotfiles-36320a75d1306bf113b618243765557d56d12960.zip
Ditch Awk version of shoal(1) for pure Bash
Diffstat (limited to 'bin')
-rwxr-xr-xbin/shoal15
1 files changed, 8 insertions, 7 deletions
diff --git a/bin/shoal b/bin/shoal
index 469ce487..2eba4a12 100755
--- a/bin/shoal
+++ b/bin/shoal
@@ -1,15 +1,16 @@
-#!/bin/sh
+#!/usr/bin/env bash
#
-# shoal(1) -- Print all the non-wildcard Host names (first
-# one per line) from an ssh_config(5) file, defaulting to
-# $HOME/.ssh/config.
+# shoal(1) -- Print all the non-wildcard Host names (first one per line) from
+# an ssh_config(5) file, defaulting to $HOME/.ssh/config.
#
# Author: Tom Ryder <tom@sanctum.geek.nz>
# Copyright: 2014
# License: Public domain
#
-
-prog='$1 == "Host" && $2 !~ /[^a-z0-9_-]/ {print $2}'
-awk "$prog" "${1:-$HOME/.ssh/config}"
+while read -r option value _ ; do
+ if [[ $option == 'Host' && $value != *[^[:alnum:]_-]* ]] ; then
+ printf '%s\n' "$value"
+ fi
+done < "${1:-$HOME/.ssh/config}"