|
37 | 37 |
|
38 | 38 | ## @par Usage |
39 | 39 | # |
40 | | -## In you ~/.bashrc, add the following lines to enable completion for |
| 40 | +## In your ~/.bashrc, add the following lines to enable completion for |
41 | 41 | ## all your argsparse-written scripts: |
42 | 42 | ## |
43 | 43 | ## @code |
|
48 | 48 | ## @par Required configuration |
49 | 49 | # |
50 | 50 | ## 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 | +# |
62 | 52 | ## @li "sourcepath" shell option must be enabled. This should be |
63 | 53 | ## enabled by default, but you can enforce it by running: |
64 | 54 | ## |
|
75 | 65 | ## @endcode |
76 | 66 | ## |
77 | 67 | ## @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. |
83 | 75 | ## |
84 | 76 | ## |
85 | 77 | # |
@@ -174,6 +166,8 @@ __argsparse_complete() { |
174 | 166 | ( |
175 | 167 | set +o posix |
176 | 168 | ARGSPARSE_COMPLETION_MODE=1 |
| 169 | + shopt -s expand_aliases |
| 170 | + unalias -a |
177 | 171 | . "$script" 2>/dev/null || return |
178 | 172 | longs=( "${!__argsparse_options_descriptions[@]}" ) |
179 | 173 | longs=( "${longs[@]/#/--}" ) |
|
0 commit comments