Skip to content

Commit 5204cff

Browse files
author
Damien Nadé
committed
argsparse-completion.sh:
* some documentation update * enforcing expand_aliases in subshell + removing all aliases
1 parent 95252a9 commit 5204cff

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed

argsparse-completion.sh

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
## @par Usage
3939
#
40-
## In you ~/.bashrc, add the following lines to enable completion for
40+
## In your ~/.bashrc, add the following lines to enable completion for
4141
## all your argsparse-written scripts:
4242
##
4343
## @code
@@ -48,17 +48,7 @@
4848
## @par Required configuration
4949
#
5050
## argsparse-completion relies on a few shell settings:
51-
52-
## @li "expand_aliases" @n
53-
## This the expansion of an alias. Aliases are enabled by default in
54-
## interactive mode.
55-
##
56-
## @code
57-
## shopt expand_aliases
58-
## @endcode
59-
##
60-
61-
##
51+
#
6252
## @li "sourcepath" shell option must be enabled. This should be
6353
## enabled by default, but you can enforce it by running:
6454
##
@@ -75,11 +65,13 @@
7565
## @endcode
7666
##
7767
## @par Limitations
78-
## @li The completed script will be sourced, up to the
79-
## argsparse_parse_options function() call. This means the script
80-
## should not performed any side effect (like file system alteration
81-
## - file creation, ), and should avoid time-consuming tasks up to
82-
## this point
68+
#
69+
## @li Every time the completion is invoked, the completed script will
70+
## be sourced, up to either the argsparse_parse_options() function
71+
## call or any the first return top-level statement. This means that
72+
## up to this point the script should not have any side effect (like
73+
## file system alteration, network connections, ...), and should
74+
## avoid time-consuming tasks up to this point.
8375
##
8476
##
8577
#
@@ -174,6 +166,8 @@ __argsparse_complete() {
174166
(
175167
set +o posix
176168
ARGSPARSE_COMPLETION_MODE=1
169+
shopt -s expand_aliases
170+
unalias -a
177171
. "$script" 2>/dev/null || return
178172
longs=( "${!__argsparse_options_descriptions[@]}" )
179173
longs=( "${longs[@]/#/--}" )

0 commit comments

Comments
 (0)