mirror of
https://github.com/octoleo/hosts.git
synced 2024-05-28 20:30:47 +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
|
EOM
|
||||||
show() {
|
show() {
|
||||||
if [[ -n "$1" ]]; then
|
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
|
else
|
||||||
$_me help show
|
$_me help show
|
||||||
exit 1
|
exit 1
|
||||||
|
|
Loading…
Reference in New Issue
Block a user