Skip to content

Commit

Permalink
Fixing bug
Browse files Browse the repository at this point in the history
  • Loading branch information
John Pfuntner committed Nov 8, 2024
1 parent 3fdb6e7 commit 41a0b15
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions bin/ssh-hosts
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,17 @@ with open(os.path.expanduser('~/.ssh/config')) as stream:
if match:
hosts[hostname][match.group(1)] = match.group(2)

log.debug(f'{hosts=}')

if args.regexps:
# apply regular expressions
pos = 0
hostnames = list(hosts.keys())
while pos < len(hostnames):
if any([re.search(regexp[1:] if regexp.startswith('!') else regexp, hostnames[pos]) for regexp in args.regexps]) == args.regexps[0].startswith('!'):
log.info(f'Removing {hostnames[pos]!r}')
del hosts[hostnames[pos]]
else:
pos += 1
pos += 1

if args.list or args.comma:
print((',' if args.comma else '\n').join(hosts))
Expand Down

0 comments on commit 41a0b15

Please sign in to comment.