1
0
mirror of https://github.com/octoleo/hosts.git synced 2024-05-28 20:30:47 +00:00
Commit Graph

232 Commits

Author SHA1 Message Date
William Melody
68b421f95a Combine Environment and Globals. 2020-06-07 12:45:07 -07:00
William Melody
a09e7b2468 Improve section dividers. 2020-06-07 12:40:44 -07:00
William Melody
dfbc83e12c Improve _debug(). 2020-06-07 12:34:55 -07:00
William Melody
fff87648d4 Update version to 3.5.1 2020-05-17 11:39:26 -07:00
William Melody
1d948837d0 Use _exit_1 with non-help error messages. 2020-05-17 11:28:31 -07:00
William Melody
2f6290f3d4 Quote arguments to help. 2020-05-17 11:24:38 -07:00
William Melody
16a672d52a Improve code formatting. 2020-05-17 11:10:12 -07:00
William Melody
16a95406fe Replace return 1 with message with _return_1. 2020-05-17 11:03:24 -07:00
William Melody
5a7d0cca91 Replace _die() with _exit_1(). 2020-05-17 11:01:25 -07:00
William Melody
40be65b7da _verify_write_permissions() doesn't accept arguments. 2020-05-17 10:57:33 -07:00
William Melody
affd8d8657 Use brackets in _verify_write_permissions(). 2020-05-17 10:55:36 -07:00
William Melody
6e751065de Improve backups argument handling. 2020-05-17 10:54:03 -07:00
William Melody
3e326dad13 Unenable shellcheck SC2183 for printf format string. 2020-05-17 10:37:51 -07:00
William Melody
6bde3438c6 Don't use $/${} with arithmetic variables.
ShellCheck SC2004
https://github.com/koalaman/shellcheck/wiki/SC2004
2020-05-17 10:34:59 -07:00
William Melody
ca43d92d85 Remove unused variable. 2020-05-17 10:33:15 -07:00
William Melody
bc06de7476 Update version to 3.5.0 2020-04-22 12:15:15 -07:00
William Melody
88030b8a51 Return 1 from show when entry not found.
GH-9
2020-04-22 12:07:35 -07:00
William Melody
5112c3e6a0 Use consistent terminology in function documentation.
GH-9
2020-04-22 12:07:22 -07:00
William Melody
2f5f610e3c Reformat exit status documentation.
GH-9
2020-04-22 12:07:13 -07:00
William Melody
59bb99ea34 Merge branch 'sleepyghost01-feature/add-exit-codes'
* sleepyghost01-feature/add-exit-codes:
  Add exit code documentation
2020-04-22 12:05:37 -07:00
William Melody
40b76d2e26 Update version to 3.4.3 2020-04-16 11:48:00 -07:00
Amin Mousavi
a67e4c997b Add exit code documentation
Problem:
It's not clear in documentation which exit code will return for each command specially commands that might return 1 when there's no action to do.

Solution:
- All possible documentation has been added.
- .ignorefile has been missed which could cause problem for other contribution so I add one by help of https://www.gitignore.io
2020-04-16 12:11:40 +02:00
William Melody
4088591bb2 Update version to 3.4.2 2020-04-14 13:21:03 -07:00
William Melody
952d848157 Update version to 3.4.1 2020-04-14 13:06:40 -07:00
William Melody
886599394e Update version to 3.4.0 2020-04-14 10:13:31 -07:00
William Melody
9cbc6ddafb Update version to 3.3.3 2020-04-13 16:49:08 -07:00
William Melody
cd3d9ef2b5 Update version to 3.3.2 2020-04-13 15:07:41 -07:00
William Melody
e88cd0b16a Match variable space in duplicate detection. 2020-04-12 16:52:47 -07:00
William Melody
7b8b4db54b Escape newlines consistently. 2020-04-12 16:50:30 -07:00
William Melody
c41b0ada74 Move documentation comment to more logical position. 2020-04-12 15:39:18 -07:00
William Melody
5bb8add6de Update version to 3.3.1 2020-04-08 21:42:38 -07:00
William Melody
c14c1a5213 Avoid less in backups show. 2020-04-08 21:29:57 -07:00
William Melody
fb67d7b510 Just use diff in backups compare. 2020-04-08 21:25:01 -07:00
William Melody
7fc3b994b4 Update version to 3.3.0 2020-04-08 18:01:24 -07:00
William Melody
ce605e8c0c Add delete alias for remove. 2020-04-08 17:58:05 -07:00
William Melody
7301dc38f1 Improve option parsing and command detection. 2020-04-08 17:44:51 -07:00
William Melody
5d9f876b13 Improve add formatting. 2020-04-08 17:27:11 -07:00
William Melody
902c996b3b Improve output formatting. 2020-04-08 16:43:07 -07:00
William Melody
3a810cf384 Update version to 3.2.5 2020-03-30 17:44:14 -07:00
William Melody
5916a18908 Avoid relying on hosts being in $PATH.
gh-8
2020-03-30 17:41:51 -07:00
William Melody
3ccfbb5bc1 Update version to 3.2.4 2020-03-23 17:54:20 -07:00
William Melody
f67a88af94 Add URL to help text. 2020-03-23 17:52:58 -07:00
William Melody
c864eff0ec Update version to 3.2.3 2020-03-18 12:04:42 -07:00
William Melody
925de9dca5 Update GitHub username.
alphabetum -> xwmx
2020-03-18 12:02:45 -07:00
William Melody
e9a7ecd6a7 Update version to 3.2.2 2020-03-16 22:36:18 -07:00
William Melody
0f3c59bd86 Rename SED_COMMAND variable to _SED_I_COMMAND. 2020-03-16 20:46:34 -07:00
William Melody
d91a4406a7 Update version to 3.2.1 2020-03-16 15:07:52 -07:00
William Melody
774505abc0 Update version to 3.2.0 2020-03-15 18:55:34 -07:00
William Melody
659bbb4755 Use consistent argument name in documentation. 2020-03-15 18:51:42 -07:00
William Melody
0247826a41 Indicate in help text that --skip-backup is optional. 2020-03-15 18:49:03 -07:00
William Melody
4eed5251da Add backups command.
`backups` provides subcommands for managing backups of the hosts file.
2020-03-15 18:42:16 -07:00
William Melody
ada8cb6019 Handle multiple hostnames with block and unblock. 2020-03-15 17:10:29 -07:00
William Melody
ab2a193371 Update version to 3.1.3 2020-03-15 17:08:11 -07:00
William Melody
4be5105f67 Modify sed platform handling.
Use array for `sed -i` command so arguments are passed as expected. This
resolves an issue where a copy of the hosts file is created with quotes
appended to the filename.
2020-03-15 17:03:53 -07:00
William Melody
bfbe08a65b Update version to 3.1.2 2020-03-15 11:45:39 -07:00
William Melody
c680c02007 Update grammar in comment. 2020-03-15 11:36:47 -07:00
William Melody
fa9ba543f5 Set noglob to disable filename expansion (globbing). 2020-03-15 11:30:08 -07:00
William Melody
850f210a4f Assign command parameters as quoted array.
Satisfies Shellcheck SC2206
https://github.com/koalaman/shellcheck/wiki/SC2206
2020-03-14 19:03:50 -07:00
William Melody
fe48de86f1 Update version to 3.1.1 2019-11-21 19:28:51 -08:00
William Melody
e10d116510 Handle platform-specific sed -i requirements.
`sed -i` on macOS requires an extension, but on Linux that extension can
cause errors. Use a platform check to only include the extension on
macOS.

resolves gh-5
2019-11-21 19:17:45 -08:00
William Melody
060306f28b Use { ..; } instead of (..) to avoid subshell overhead.
ShellCheck SC2235: https://github.com/koalaman/shellcheck/wiki/SC2235
2019-11-04 17:01:16 -08:00
William Melody
1ed6504bc2 Update version to 3.1.0 2018-08-14 11:31:02 -07:00
William Melody
789a0797c2 Improve search behavior.
Search comments in addition to IPs and hostnames.

Call grep twice, excluding commented lines first before searching.
2018-08-14 11:31:02 -07:00
William Melody
af412412f2 Bump version to 3.0.1 2018-05-15 10:11:32 -07:00
William Melody
5ee732006d Add comments about option parsing. 2018-05-15 08:37:24 -07:00
William Melody
647c4329c9 Update version to 3.0.0 2018-05-14 21:27:39 -07:00
William Melody
1738ba9ad3 Use double square brackets for option parsing while test. 2018-05-14 21:22:26 -07:00
William Melody
0c11a1939e Simplify help argument handling. 2018-05-14 21:19:36 -07:00
William Melody
dfcb37b3b6 Remove unused option normalization.
This program only really accepts one short argument, `-h`, so this
extra complexity isn't necessary.
2018-05-14 20:45:35 -07:00
William Melody
79a5aa95fc Update boilerplate to latest from bash-boilerplate.
Source: https://github.com/alphabetum/bash-boilerplate
2018-05-14 20:22:35 -07:00
William Melody
7f3f6a95ab Simplify regular expression variable handling.
- Remove '_target' prefixes.
- Declare and assign separately.
2018-05-14 20:12:19 -07:00
William Melody
6da4b7475f Update coding style.
- Quote variables throughout.
- Use underscore prefixes to denote script-local variables and avoid
  identifier conflicts.
- Add spacing for better statement grouping.
2018-05-14 20:03:32 -07:00
William Melody
661fa3b114 Use updated _join() implementation.
Source: https://github.com/alphabetum/bash-boilerplate
2018-05-14 18:46:52 -07:00
William Melody
dd25af8c99 Use updated _load_commands() implementation.
Source: https://github.com/alphabetum/bash-boilerplate
2018-05-14 18:42:21 -07:00
William Melody
2a5a18cf85 Bump version to 2.4.3
Fix misalignment between version numbers in package.json and
`$_VERSION`.
2018-05-09 10:36:18 -07:00
William Melody
746780fbbe Use explicit escaping for backslashes in all contexts.
ShellCheck SC1117
https://github.com/koalaman/shellcheck/wiki/SC1117
2018-04-15 15:01:34 -07:00
William Melody
80edd464b6 Use explicit escaping for "\\n" newlines.
Backslash is literal, so explicitly escape it rather than rely on
fallback behavior.

ShellCheck SC1117
https://github.com/koalaman/shellcheck/wiki/SC1117
2018-04-15 14:55:26 -07:00
William Melody
d02f46a99e Bump version to 2.4.1. 2017-03-01 20:55:06 -08:00
William Melody
d700037f18 Simplify header comment. 2017-03-01 20:54:08 -08:00
William Melody
32c5be4dcc Revert "Prefix _debug strings with '•' to avoid highlighting bugs."
This reverts commit 921afd7155.

The reverted commit did not succeed in fixing highlighting bugs.
2017-03-01 20:51:36 -08:00
William Melody
921afd7155 Prefix _debug strings with '•' to avoid highlighting bugs.
GitHub's syntax highlighting doesn't work well when strings contain
function names with parentheses, so add character to the beginning of
the string to see whether this makes it better.
2017-03-01 20:46:49 -08:00
William Melody
f5d0f827e0 Bump version to 2.4.0. 2017-03-01 20:24:12 -08:00
William Melody
d94af2c25b Update comments in "Globals" section. 2017-03-01 20:22:41 -08:00
William Melody
db7ac727f1 Rename $DEFAULT_COMMAND to $HOSTS_DEFAULT_COMMAND. 2017-03-01 20:21:06 -08:00
William Melody
6c0254895f Support full list operations in hosts with no subcommand. 2017-03-01 20:18:26 -08:00
William Melody
05ba7bdc03 Quote argument to unset.
ShellCheck SC2184: Quote arguments to unset so they're not glob expanded.

https://github.com/koalaman/shellcheck/wiki/SC2184
2017-03-01 19:59:01 -08:00
William Melody
404ee19742 Add _verify_write_permissions() checks to block and unblock. 2017-03-01 19:32:49 -08:00
William Melody
3237818607 Expand documentation comment for _verify_write_permissions(). 2017-03-01 18:28:21 -08:00
William Melody
b7b186267d Bump version to 2.3.1. 2017-03-01 16:29:36 -08:00
William Melody
e0790f6a4c Bump version to 2.3.0. 2017-03-01 16:25:03 -08:00
William Melody
99b175f134 Add --auto-sudo option and expand option documentation.
Using `sudo` within a script is generally considered poor practice, so
by default an error message is printed when the user attempts to perform
a write operation without sufficient permissions.

One way to deal avoid this error message is to alias `hosts` to `sudo
hosts`, but this then requires `sudo` for all operations and not just
write operations.

The new `--auto-sudo` option flag provides a way to automatically invoke
a write command with `sudo` when the user doesn't have write
permissions.

In order to provide cleaner documentation for this option, include more
option documentation in README.md.
2017-03-01 16:18:05 -08:00
William Melody
0925735153 Bump version to 2.2.0. 2017-03-01 14:29:04 -08:00
William Melody
347189c059 Add search usage to primary help output.
Update README.md to more accurately reflect `help` output.
2017-03-01 13:45:19 -08:00
William Melody
265a1c732e Add block and unblock functions.
`block` and `unblock` set the given <hostname> to the IPv4 and IPv6
loopback addresses.
2017-03-01 13:43:10 -08:00
William Melody
73ffcffb38 Add hosts search function.
`hosts search` wraps `hosts list`, providing a slightly more intuitive
interface.
2017-03-01 12:46:27 -08:00
William Melody
703d665a32 Use read with -r option.
ShellCheck SC2162: read without -r mangle backslashes

https://github.com/koalaman/shellcheck/wiki/SC2162
2017-03-01 12:05:59 -08:00
William Melody
4194b25459 Use HEREDOC rather than EOM to define heredocs. 2017-03-01 11:42:26 -08:00
William Melody
f7675f360e Bump version to 2.1.6. 2016-03-24 17:32:26 -07:00
William Melody
149a51662e Handle blank arguments string when assigning to $_RAW_OPTIONS.
When `$*` is specified with quotes and braces as `"${*}"`, a blank
argument array results in an error in older versions of bash. Remove
the braces to avoid this error.
2016-03-24 17:30:30 -07:00
William Melody
187222614a Use braces in all variable references.
Braces are only required in certain cases, but the cognitive overhead in
keeping track of which cases require braces can be reduced by simply
always using them.

Example: `${NAME}`

Retain more widely-used braces `$NAME` convention in documentation.
2016-02-23 18:14:21 -08:00