Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better support for OpenBSD #4584

Closed
wants to merge 16 commits into from
32 changes: 32 additions & 0 deletions share/completions/pfctl.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
complete -c pfctl -s s --description 'Show a filter parameter by modifier' -xa \
'queue\t"Show loaded queue definitions" \
rules\t"Show loaded filter rules" \
Anchors\t"Show anchors attached to main ruleset" \
states\t"Show state table"
Sources\t"Show source tracking table" \
info\t"Show filter information" \
labels\t"Show stats of labeled filter rules" \
timeouts\t"Show global timeouts" \
memory\t"Show pool memory hard limits" \
Tables\t"Show the list of tables" \
osfp\t"Show a list of OS fingerprints" \
Interfaces\t"List PF interfaces/drivers" \
all\t"Everything."'
complete -c pfctl -s F --description 'Flush filter params specified by mod' -xa \
'rules\t"Flush filter rules" \
states\t"Flush state table" \
Sources\t"Flush source tracking table" \
info\t"Flush filter information" \
Tables\t"Flush the tables" \
ospf\t"Flush the passive OS fingerprints" \
all\t"Flush everything"'
complete -c pfctl -s T --description 'Table command' -xa \
'kill\t"Kill a table." \
flush\t"Flush addresses of a table" \
add\t"Add one or more addresses in table" \
delete\t"Delete one or more addresses from a table" \
expire\t"Delete addresses where stats cleared > N seconds" \
replace\t"Replace the addresses of the table" \
show\t"Show the contents of a table" \
test\t"Test if the given addresses match a table" \
zero\t"Clear all the stats of a table"'
9 changes: 9 additions & 0 deletions share/completions/pkg_add.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#completion for pkg_add

complete -c pkg_add -o D -d 'failsafe to overwrite' -xa 'allversions arch checksum dontmerge donttie downgrade installed libdepends nonroot paranoid repair scripts SIGNER snap unsigned updatedepends'
complete -c pkg_add -o V -d 'Turn on stats'
complete -c pkg_add -o a -d 'Automated package installation'
complete -c pkg_add -o h -d 'Print help'
complete -c pkg_add -o u -d 'Update packages'
complete -c pkg_add -o z -d 'Fuzzy match'

8 changes: 8 additions & 0 deletions share/completions/pkg_delete.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#completion for pkg_delete


complete -c pkg_delete -a '(__fish_print_packages)' --description 'Package'

complete -c pkg_delete -o a -d 'Delete unsed deps'
complete -c pkg_delete -o V -d 'Turn on stats'

5 changes: 5 additions & 0 deletions share/completions/pkg_info.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#completion for pkg_info


complete -c pkg_info -a '(__fish_print_packages)' --description 'Package'

3 changes: 3 additions & 0 deletions share/completions/rcctl.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

complete -c rcctl -xa 'check ls reload restart stop start disable enable' -n 'not __fish_seen_subcommand_from list check ls reload restart stop start enable disable'
complete -c rcctl -n '__fish_seen_subcommand_from check reload restart stop start enable disable' -xa '(set -l files /etc/rc.d/*; string replace "/etc/rc.d/" "" -- $files)'
4 changes: 4 additions & 0 deletions share/completions/signify.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
complete -c signify -n '__fish_seen_subcommand_from' -s C --description 'Verify a signed checksum list'
complete -c signify -n '__fish_seen_subcommand_from' -s G --description 'Generate a new key pair'
complete -c signify -n '__fish_seen_subcommand_from' -s S --description 'Sign specified message'
complete -c signify -n '__fish_seen_subcommand_from' -s V --description 'Verify a signed message and sig'
4 changes: 4 additions & 0 deletions share/completions/vmctl.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

complete -c vmctl -xa 'console create load log reload reset start status stop pause unpause send receive' -n 'not __fish_seen_subcommand_from list console create load log reload reset start status stop pause unpause send receive'
complete -c vmctl -n '__fish_seen_subcommand_from console reload reset start status stop pause unpause send receive' -xa '(vmctl status | string match -e -v "MAXMEM" | string replace -r "^(\s+\S+\s+){7}" "")'

2 changes: 1 addition & 1 deletion share/functions/__fish_print_filesystems.fish
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function __fish_print_filesystems -d "Print a list of all known filesystem types"
set -l fs adfs affs autofs coda coherent cramfs devpts efs ext ext2 ext3
set -l fs adfs affs autofs coda coherent cramfs devpts efs ext ext2 ext3 ffs
set -a fs hfs hpfs iso9660 jfs minix msdos ncpfs nfs ntfs proc qnx4 ramfs
set -a fs reiserfs romfs smbfs sysv tmpfs udf ufs umsdos vfat xenix xfs xiafs
# Mount has helper binaries to mount filesystems
Expand Down
7 changes: 6 additions & 1 deletion share/functions/__fish_print_interfaces.fish
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ function __fish_print_interfaces --description "Print a list of known network in
set -l interfaces /sys/class/net/*
string replace /sys/class/net/ '' $interfaces
else # OSX/BSD
command ifconfig -l | string split ' '
set -l os (uname)
if string match -e -q "BSD" -- $os
command ifconfig | string match -e -r '^[a-z]' | string replace -r ':.*' '' | string split ' '
else
command ifconfig -l | string split ' '
end
end
end
14 changes: 10 additions & 4 deletions share/functions/__fish_print_packages.fish
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,20 @@ function __fish_print_packages

# Pkg is fast on FreeBSD and provides versioning info which we want for
# installed packages
if begin
type -q -f pkg
and test (uname) = "FreeBSD"
end
if type -q -f pkg
pkg query "%n-%v"
return
end

# pkg_info on OpenBSD provides versioning info which we want for
# installed packages but, calling it directly can cause delays in
# returning information if another pkg_* tool have a lock.
# Listing /var/db/pkg is a clean alternative.
if type -q -f pkg_add
set -l files /var/db/pkg/*; string replace '/var/db/pkg/' '' -- $files
return
end

# Caches for 5 minutes
if type -q -f pacman
set cache_file $XDG_CACHE_HOME/.pac-cache.$USER
Expand Down
21 changes: 14 additions & 7 deletions share/tools/create_manpage_completions.py
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ def parse_and_output_man_pages(paths, output_directory, show_progress):
add_diagnostic("Successfully parsed %d / %d pages" % (successful_count, total_count), BRIEF_VERBOSE)
flush_diagnostics(sys.stderr)

def get_paths_from_manpath():
def get_paths_from_man_locations():
# Return all the paths to man(1) and man(8) files in the manpath
import subprocess, os
proc = None
Expand All @@ -866,7 +866,6 @@ def get_paths_from_manpath():
parent_paths = os.getenv("MANPATH").strip().split(':')
else:
# Some systems have manpath, others have `man --path` (like Haiku).
# TODO: Deal with systems that have neither (OpenBSD)
for prog in [['manpath'], ['man', '--path']]:
try:
proc = subprocess.Popen(prog, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
Expand All @@ -876,10 +875,18 @@ def get_paths_from_manpath():
manpath, err_data = proc.communicate()
parent_paths = manpath.decode().strip().split(':')
if (not parent_paths) or (proc and proc.returncode > 0):
# HACK: Use some fallback in case we can't get anything else.
# `mandoc` does not provide `manpath` or `man --path` and $MANPATH might not be set, so just use the default for mandoc (minus /usr/X11R6/man, because that's not relevant).
# HACK: Use some fallbacks in case we can't get anything else.
# `mandoc` does not provide `manpath` or `man --path` and $MANPATH might not be set.
# The alternative is reading its config file (/etc/man.conf)
sys.stderr.write("Unable to get the manpath, falling back to /usr/share/man:/usr/local/share/man. Please set $MANPATH if that is not correct.\n")
if os.path.isfile('/etc/man.conf'):
data = open('/etc/man.conf', 'r')
for line in data:
if ('manpath' in line or 'MANPATH' in line):
p = line.split(' ')[1]
p = p.split()[0]
parent_paths.append(p)
if (not parent_paths):
sys.stderr.write("Unable to get the manpath, falling back to /usr/share/man:/usr/local/share/man. Please set $MANPATH if that is not correct.\n")
parent_paths = ["/usr/share/man", "/usr/local/share/man"]
result = []
for parent_path in parent_paths:
Expand Down Expand Up @@ -943,8 +950,8 @@ def usage(script_name):
assert False, "unhandled option"

if use_manpath:
# Fetch all man1 and man8 files from the manpath
file_paths.extend(get_paths_from_manpath())
# Fetch all man1 and man8 files from the manpath or man.conf
file_paths.extend(get_paths_from_man_locations())

if cleanup_directories:
for cleanup_dir in cleanup_directories:
Expand Down