blob: eb376cbc95be2e1c2f1a10c2dc977ea2477a43a1 (
plain) (
tree)
|
|
#!/usr/bin/env bash
#
# sls(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
#
# Start by assuming we should parse all hosts
declare -i sls
sls=1
# Iterate through the config
while read -r option value _ ; do
# "### sls" and "### nosls" toggles parsing
case $option in
'###')
case $value in
nosls)
sls=0
;;
sls)
sls=1
;;
esac
;;
'Host')
if ((sls)) && [[ $value != *[^[:alnum:]_-]* ]] ; then
printf '%s\n' "$value"
fi
;;
esac
done < "${1:-$HOME/.ssh/config}"
|