Menu

patch lines

genzj

Patch Lines

Patch lines are subject of a [hosts diff] file.

Generally, there are two types of patch lines, action line and info line. Action lines scan lines in hosts file one by one, receive each line as input and output one or more lines. They can modify or delete line(s) of hosts file, or insert line(s) into it. Meanwhile, info lines only output some information to log of pyHostsPatcher, to warn users or declare purpose of current [hosts diff] file, which have no privilege to modify the content of hosts file.

Only two types of info line supported, they are:

  • Prompt for users, can be seen by anyone try to adopt this [hosts diff] file:

    # Some information

  • Prompt for debuggers, can be seen only in debug output:

    #- Some debug information

At present(version 0.9), three generic types of action line supported, they are:

  • Add a line to hosts lines:

    + IP hostname # comments

    + # Pure comment line

  • Remove a line from hosts lines

    - IP # comments

    - hostname # comments

  • Replace all occurrences of a certain IP address

    <> old-IP new-IP # comments

NOTICE: Add a line will remove duplicated lines which have the same hostname but different IP addresses with the line to add. If there is a line identical to the line to add, the former will be kept and no new line will be appended. But lines with same hostnames and discordant IP addresses are also wiped from final output.


Related

Wiki: hosts diff

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.