mirror of
https://github.com/octoleo/hosts.git
synced 2025-01-01 05:31:49 +00:00
Print disabled matches in show
This commit is contained in:
parent
522d189f2e
commit
bc36182773
7
hosts
7
hosts
@ -812,7 +812,12 @@ Description:
|
||||
EOM
|
||||
show() {
|
||||
if [[ -n "$1" ]]; then
|
||||
grep "^[^#]*$1" /etc/hosts
|
||||
# Run `sed` before `grep` to avoid conflict that supress `sed` output.
|
||||
disabled_records=$(sed -n "s/^\#\(disabled: .*$1.*\)$/\1/p" /etc/hosts)
|
||||
enabled_records=$(grep "^[^#]*$1" /etc/hosts)
|
||||
# Output disabled records secondly for better organization.
|
||||
[[ -n "$enabled_records" ]] && printf "%s\n" "$enabled_records"
|
||||
[[ -n "$disabled_records" ]] && printf "%s\n" "$disabled_records"
|
||||
else
|
||||
$_me help show
|
||||
exit 1
|
||||
|
Loading…
Reference in New Issue
Block a user