The behavior you describe is likely caused by bash-completion.
(What follows is based on the current version of the package (2.9), but it will be reasonably accurate for the 2.1 version you have too).
bash-completion provides a set of completion specifications (compspec) that the Readline library uses to complete words that are supplied as arguments to commands in Bash. They are defined using the
complete builtin command, usually in the form:
complete -F function command
export builtin, the function
_export is defined in
When the word to complete includes (or ends in) a
_export tries to complete it (the part to the right of the first
=, actually) as a file or directory name; when the word to complete does not include a
=, it tries to complete it as a variable name. Since the Readline library starts a new completion every time it runs across one of the characters listed in the
COMP_WORDBREAKS variable (unless the character is escaped), which usually includes
:, completion stops working after the first colon you append to a variable's value because, at that point, the word to complete is not including (or ending in) a
(Note, incidentally, that file/directory name completion starts working again if you write
export myvar=/usr/:othervar= and hit Tab).
bash-completion indeed has its own mechanism for handling special cases. For instance,
: is correctly dealt with by the compspec for
scp, which interprets what is on the right hand of a colon as a remote path. The same is not applied to
Readline's default behavior, which is triggered when a compspec for the current command is not found, is ultimately to attempt filename completion. That is why completion of
export var=/path1/:/path2/ works when bash-completion is not installed or otherwise disabled (remember that every colon starts a new completion).
What can you do, then? You have some alternatives:
File a feature request to bash-completion on GitHub.
Define your own completion function for
First, copy the compspec to the user completion file (which likely doesn't exist yet):
$ cat /usr/share/bash-completion/completions/export >>~/.bash_completion
complete -F _export export into
complete -F _export -o default export. This instructs Readline to attempt the default completion when
export's specific compspec gives no results.
Use the default completion, instead of the one provided by bash-completion.
Add to your
complete -o default -o bashdefault export
(Suggestion from bash-completion's FAQ). The downside is that you lose the ability to complete variable names and
If you are willing to become familiar enough with bash-completion, define your own
_export function, as in (2), by editing the provided one to let it handle