Skip to content

Commit 309ad27

Browse files
committed
docs: convert to markdown, remove some no longer relevant sections
This is mostly just a mechanical conversion, contentwise a bunch of things remain to be added and updated.
1 parent 49491e9 commit 309ad27

File tree

9 files changed

+162
-209
lines changed

9 files changed

+162
-209
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,5 @@ pytestdebug.log
1717
/config.status
1818
/configure
1919
/configure.lineno
20-
/doc/*.xml
21-
/doc/html*
2220
/install-sh
2321
/missing

.pre-commit-config.yaml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -116,23 +116,6 @@ repos:
116116
- scan
117117
exclude: ^CHANGELOG\.md$
118118

119-
- repo: local
120-
hooks:
121-
- id: asciidoctor
122-
name: asciidoctor
123-
language: docker_image
124-
entry: asciidoctor/docker-asciidoctor:1.15 asciidoctor
125-
args:
126-
- --out-file
127-
- /dev/null
128-
- --failure-level
129-
- WARN
130-
- --doctype
131-
- book
132-
- doc/main.txt
133-
pass_filenames: false
134-
files: ^doc/.*\.txt$
135-
136119
- repo: https://github.com/pre-commit/pre-commit-hooks
137120
rev: v4.0.1
138121
hooks:

doc/Makefile.am

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
EXTRA_DIST = \
2-
bash_completion.txt \
3-
main.txt \
4-
makeHtml.sh \
5-
styleguide.txt \
6-
testing.txt
2+
configuration.md \
3+
styleguide.md \
4+
testing.md

doc/bash_completion.txt

Lines changed: 0 additions & 65 deletions
This file was deleted.

doc/configuration.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Configuration
2+
3+
## Files
4+
5+
### `$BASH_COMPLETION_USER_FILE`
6+
7+
Sourced late by `bash_completion`, pretty much after everything else.
8+
Use this file for example to load additional completions, and to remove
9+
and override ones installed by bash_completion. Defaults to
10+
`~/.bash_completion` if unset or null.
11+
12+
### `$XDG_CONFIG_HOME/bash_completion`
13+
14+
Sourced by the `bash_completion.sh` `profile.d` script. This file is
15+
suitable for definitions of all `COMP*` environment variables below.
16+
If `$XDG_CONFIG_HOME` is unset or null,`~/.config` is
17+
used instead of it.
18+
19+
## Environment variables
20+
21+
### `BASH_COMPLETION_COMPAT_DIR`
22+
23+
Directory for pre-dynamic loading era (pre-2.0) backwards compatibility
24+
completion files that are loaded eagerly from `bash_completion` when it is
25+
loaded. If unset or null, the default compatibility directory to use is
26+
`/etc/bash_completion.d`.
27+
28+
### `COMP_CONFIGURE_HINTS`
29+
30+
If set and not null, `configure` completion will return the entire option
31+
string (e.g. `--this-option=DESCRIPTION`) so one can see what kind of data
32+
is required and then simply delete the descriptive text and add one's own
33+
data. If unset or null (default), `configure` completion will strip
34+
everything after the `=` when returning completions.
35+
36+
### `COMP_CVS_REMOTE`
37+
38+
If set and not null, `cvs commit` completion will try to complete on
39+
remotely checked-out files. This requires passwordless access to the
40+
remote repository. Default is unset.
41+
42+
### `COMP_FILEDIR_FALLBACK`
43+
44+
If set and not null, completions that look for filenames based on their
45+
"extensions" will fall back to suggesting all files if there are none
46+
matching the sought ones.
47+
48+
### `COMP_IWLIST_SCAN`
49+
50+
If set and not null, `iwconfig` completion will try to complete on
51+
available wireless networks identifiers. Default is unset.
52+
53+
### `COMP_KNOWN_HOSTS_WITH_HOSTFILE`
54+
55+
If set and not null (default), known hosts completion will complement
56+
hostnames from ssh's known_hosts files with hostnames taken from the file
57+
specified by the `HOSTFILE` shell variable (`compgen -A hostname`). If null,
58+
known hosts completion will omit hostnames from `HOSTFILE`. Omitting
59+
hostnames from `HOSTFILE` is useful if `HOSTFILE` contains many entries for
60+
local web development or ad-blocking.
61+
62+
### `COMP_KNOWN_HOSTS_WITH_AVAHI`
63+
64+
If set and not null, known hosts completion will try to use `avahi-browse`
65+
for additional completions. This may be a slow operation in some setups.
66+
Default is unset.
67+
68+
### `COMP_TAR_INTERNAL_PATHS`
69+
70+
If set and not null _before sourcing_ the `tar` completion, it will do
71+
correct path completion for tar file _contents_. If unset or null,
72+
_paths to_ tar files will be correctly completed. Unfortunately we do not
73+
have a way to make both Just Work properly at the moment. We consider it
74+
more important to have proper completion of paths to tar files than it is
75+
to have completion for their contents, so the default is unset.

doc/main.txt

Lines changed: 0 additions & 19 deletions
This file was deleted.

doc/makeHtml.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 50 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
= Coding Style Guide
1+
# Coding Style Guide
22

3-
== Introduction
3+
## Introduction
44

55
This document attempts to explain the basic styles and patterns that
6-
are used in the bash completion. New code should try to conform to
6+
are used in the bash completion. New code should try to conform to
77
these standards so that it is as easy to maintain as existing code.
88
Of course every rule has an exception, but it's important to know
99
the rules nonetheless!
@@ -13,103 +13,107 @@ codebase, who are in the process of getting their code reviewed.
1313
Before getting a review, please read over this document and make
1414
sure your code conforms to the recommendations here.
1515

16-
== Indentation
16+
## Indentation
1717

1818
Indent step should be 4 spaces, no tabs.
1919

20-
== Globbing in case labels
20+
## Globbing in case labels
2121

2222
Avoid "fancy" globbing in case labels, just use traditional style when
23-
possible. For example, do "--foo|--bar)" instead of "--@(foo|bar))".
23+
possible. For example, do `--foo|--bar)` instead of `--@(foo|bar))`.
2424
Rationale: the former is easier to read, often easier to grep, and
2525
doesn't confuse editors as bad as the latter, and is concise enough.
2626

27-
== [[ ]] vs [ ]
27+
## `[[ ]]` vs `[ ]`
2828

29-
Always use [[ ]] instead of [ ]. Rationale: the former is less error
29+
Always use `[[ ]]` instead of `[ ]`. Rationale: the former is less error
3030
prone, more featureful, and slightly faster.
3131

32-
== Line wrapping
32+
## Line wrapping
3333

3434
Try to wrap lines at 79 characters. Never go past this limit, unless
3535
you absolutely need to (example: a long sed regular expression, or the
3636
like). This also holds true for the documentation and the testsuite.
3737
Other files, like ChangeLog, or COPYING, are exempt from this rule.
3838

39-
== $(...) vs \`...`
39+
## `$( )` vs backticks
4040

4141
When you need to do some code substitution in your completion script,
42-
you *MUST* use the $(...) construct, rather than the \`...`. The former
42+
you _MUST_ use the `$(...)` construct, rather than backticks. The former
4343
is preferable because anyone, with any keyboard layout, is able to
4444
type it. Backticks aren't always available, without doing strange
4545
key combinations.
4646

47-
== -o filenames
47+
## `-o filenames`
4848

49-
As a rule of thumb, do not use "complete -o filenames". Doing it makes
49+
As a rule of thumb, do not use `complete -o filenames`. Doing it makes
5050
it take effect for all completions from the affected function, which
5151
may break things if some completions from the function must not be
52-
escaped as filenames. Instead, use "compopt -o filenames" to turn on
53-
"-o filenames" behavior dynamically when returning completions that
52+
escaped as filenames. Instead, use `compopt -o filenames` to turn on
53+
`-o filenames` behavior dynamically when returning completions that
5454
need that kind of processing (e.g. file and command names). The
55-
_filedir and _filedir_xspec helpers do this automatically whenever
55+
`_filedir` and `_filedir_xspec` helpers do this automatically whenever
5656
they return some completions.
5757

58-
== `[[ ${COMPREPLY-} == *= ]] && compopt -o nospace`
58+
## `[[ ${COMPREPLY-} == *= ]] && compopt -o nospace`
5959

6060
The above is functionally a shorthand for:
6161

62-
if [[ ${#COMPREPLY[@]} -eq 1 && ${COMPREPLY[0]} == *= ]]; then
63-
compopt -o nospace
64-
fi
62+
```bash
63+
if [[ ${#COMPREPLY[@]} -eq 1 && ${COMPREPLY[0]} == *= ]]; then
64+
compopt -o nospace
65+
fi
66+
```
6567

6668
It is used to ensure that long options' name won't get a space
67-
appended after the equal sign. Calling compopt -o nospace makes sense
69+
appended after the equal sign. Calling `compopt -o nospace` makes sense
6870
in case completion actually occurs: when only one completion is
69-
available in COMPREPLY.
71+
available in `COMPREPLY`.
7072

71-
== `$split && return`
73+
## `$split && return`
7274

73-
Should be used in completions using the -s flag of _init_completion,
74-
or other similar cases where _split_longopt has been invoked, after
75-
$prev has been managed but before $cur is considered. If $cur of the
76-
form --foo=bar was split into $prev=--foo and $cur=bar and the $prev
77-
block did not process the option argument completion, it makes sense
78-
to return immediately after the $prev block because --foo obviously
75+
Should be used in completions using the `-s` flag of `_init_completion`,
76+
or other similar cases where `_split_longopt` has been invoked, after
77+
`$prev` has been managed but before `$cur` is considered. If `$cur` of the
78+
form `--foo=bar` was split into `prev=--foo` and `cur=bar`, and the `$prev`
79+
block did not process the option argument completion, it makes sense to return
80+
immediately after the $prev block because`--foo` obviously
7981
takes an argument and the remainder of the completion function is
8082
unlikely to provide meaningful results for the required argument.
8183
Think of this as a catch-all for unknown options requiring an
8284
argument.
8385

8486
Note that even when using this, options that are known to require an
8587
argument but for which we don't have argument completion should be
86-
explicitly handled (non-completed) in the $prev handling block because
87-
--foo=bar options can often be written without the equals sign, and in
88+
explicitly handled (non-completed) in the `$prev` handling block because
89+
`--foo=bar` options can often be written without the equals sign, and in
8890
that case the long option splitting does not occur.
8991

90-
== Use arithmetic evaluation
92+
## Use arithmetic evaluation
9193

9294
When dealing with numeric data, take advantage of arithmetic evaluation.
93-
In essence, use (( ... )) whenever it can replace [[ ... ]] because the
94-
syntax is more readable; no need for $-prefixes, numeric comparison etc
95+
In essence, use `(( ... ))` whenever it can replace `[[ ... ]]` because the
96+
syntax is more readable; no need for `$`-prefixes, numeric comparison etc
9597
operators are more familiar and easier on the eye.
9698

97-
== Array subscript access
99+
## Array subscript access
98100

99101
Array subscripts are arithmetic expressions, take advantage of that.
100-
E.g. write ${foo[bar]}, not ${foo[$bar]}, and similarly ${foo[bar+1]}
101-
vs ${foo[((bar+1))]} or ${foo[$((bar+1))]}, ${foo[--i]} vs ${foo[((--i))]}.
102+
E.g. write `${foo[bar]}`, not `${foo[$bar]}`, and similarly `${foo[bar+1]}`
103+
vs `${foo[((bar+1))]}` or `${foo[$((bar+1))]}`, `${foo[--i]}` vs
104+
`${foo[((--i))]}`.
102105

103-
== Loop variable names
106+
## Loop variable names
104107

105-
Use i, j, k for loop-local indices; n and m for lengths; some other descriptive
106-
name typically based on array name but in singular when looping over actual
107-
values. If an index or value is to be accessed later on instead of being just
108-
locally for looping, use a more descriptive and specific name for it.
108+
Use `i`, `j`, `k` for loop-local indices; `n` and `m` for lengths; some other
109+
descriptive name typically based on array name but in singular when looping
110+
over actual values. If an index or value is to be accessed later on instead of
111+
being just locally for looping, use a more descriptive and specific name for
112+
it.
109113

110-
== Function names
114+
## Function names
111115

112-
Use the _comp_ prefix for all function names, and _comp_cmd_ for functions
116+
Use the `_comp_` prefix for all function names, and `_comp_cmd_` for functions
113117
defined in per command completion files and not anywhere else. Prefixing with
114118
an underscore helps keep the functions out of the way for most command name
115119
completions (except obviously ones starting with an underscore or ones that have
@@ -120,14 +124,6 @@ It is known that a lot of functions in the tree do not follow this practice.
120124
This is due to backwards compatibility reasons, but all functions introduced
121125
after version 2.11 should follow this name prefix rule.
122126

123-
/////////////////////////////////////////
127+
## Variable naming
124128

125-
== case/esac vs if
126-
127-
== quoting
128-
129-
== awk vs cut for simple cases
130-
131-
== variable naming
132-
133-
/////////////////////////////////////////
129+
To be written.

0 commit comments

Comments
 (0)