[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
10/11: bash completion: Fix & unify option parsing.
From: |
guix-commits |
Subject: |
10/11: bash completion: Fix & unify option parsing. |
Date: |
Tue, 31 May 2022 21:36:53 -0400 (EDT) |
nckx pushed a commit to branch master
in repository guix.
commit dc6d92ac93cedd65f6c99daa530b69f43f6039ec
Author: Tobias Geerinckx-Rice <me@tobias.gr>
AuthorDate: Sun May 22 02:00:00 2022 +0200
bash completion: Fix & unify option parsing.
We now correctly recognise ‘guix -Abcdef’ as equivalent to ‘guix -f’.
* etc/completion/bash/guix (_guix_is_short_option, guix_is_long_option):
New functions.
(_guix_is_dash_f, _guix_is_dash_l, _guix_is_dash_L, _guix_is_dash_m)
(_guix_is_dash_C, _guix_is_dash_p): Use them.
---
etc/completion/bash/guix | 61 ++++++++++++++++++++++++------------------------
1 file changed, 31 insertions(+), 30 deletions(-)
diff --git a/etc/completion/bash/guix b/etc/completion/bash/guix
index 6b1b70aac1..7b1f639371 100644
--- a/etc/completion/bash/guix
+++ b/etc/completion/bash/guix
@@ -117,58 +117,59 @@ _guix_is_removing ()
$result
}
+_guix_is_short_option ()
+{
+ case "${COMP_WORDS[$COMP_CWORD - 1]}" in
+ --*) false;;
+ -*$1) true ;;
+ *) false ;;
+ esac
+}
+
+_guix_is_long_option ()
+{
+ # Don't handle (non-GNU?) ‘--long-option VALUE’, as Guix doesn't either.
+ case "${COMP_WORDS[$COMP_CWORD]}" in
+ --$1=*) true ;;
+ *) false ;;
+ esac
+}
+
_guix_is_dash_f ()
{
- [ "${COMP_WORDS[$COMP_CWORD - 1]}" = "-f" ] \
- || { case "${COMP_WORDS[$COMP_CWORD]}" in
- --file=*|--install-from-file=*) true;;
- *) false;;
- esac }
+ _guix_is_short_option f ||
+ _guix_is_long_option file ||
+ _guix_is_long_option install-from-file
}
_guix_is_dash_l ()
{
- [ "${COMP_WORDS[$COMP_CWORD - 1]}" = "-l" ] \
- || { case "${COMP_WORDS[$COMP_CWORD]}" in
- --load=*) true;;
- *) false;;
- esac }
+ _guix_is_short_option l ||
+ _guix_is_long_option load
}
_guix_is_dash_L ()
{
- [ "${COMP_WORDS[$COMP_CWORD - 1]}" = "-L" ] \
- || { case "${COMP_WORDS[$COMP_CWORD]}" in
- --load-path=*) true;;
- *) false;;
- esac }
+ _guix_is_short_option L ||
+ _guix_is_long_option load-path
}
_guix_is_dash_m ()
{
- [ "${COMP_WORDS[$COMP_CWORD - 1]}" = "-m" ] \
- || { case "${COMP_WORDS[$COMP_CWORD]}" in
- --manifest=*) true;;
- *) false;;
- esac }
+ _guix_is_short_option m ||
+ _guix_is_long_option manifest
}
_guix_is_dash_C ()
{
- [ "${COMP_WORDS[$COMP_CWORD - 1]}" = "-C" ] \
- || { case "${COMP_WORDS[$COMP_CWORD]}" in
- --channels=*) true;;
- *) false;;
- esac }
+ _guix_is_short_option C ||
+ _guix_is_long_option channels
}
_guix_is_dash_p ()
{
- [ "${COMP_WORDS[$COMP_CWORD - 1]}" = "-p" ] \
- || { case "${COMP_WORDS[$COMP_CWORD]}" in
- --profile=*) true;;
- *) false;;
- esac }
+ _guix_is_short_option p ||
+ _guix_is_long_option profile
}
_guix_complete_file ()
- branch master updated (b279e778ab -> a3ea97976b), guix-commits, 2022/05/31
- 03/11: gnu: caf: Update to 0.18.6., guix-commits, 2022/05/31
- 01/11: gnu: foomatic-filters: Use project home page., guix-commits, 2022/05/31
- 06/11: gnu: fprintd: Remove input labels., guix-commits, 2022/05/31
- 05/11: gnu: fprintd: Fix build., guix-commits, 2022/05/31
- 08/11: gnu: libfprint: Update to 1.94.4., guix-commits, 2022/05/31
- 07/11: gnu: fprintd: Update to 1.94.2., guix-commits, 2022/05/31
- 10/11: bash completion: Fix & unify option parsing.,
guix-commits <=
- 04/11: gnu: beancount: Update to 2.3.5., guix-commits, 2022/05/31
- 09/11: gnu: services: Update setuid service description., guix-commits, 2022/05/31
- 11/11: gnu: corefreq: Update to 1.90.1., guix-commits, 2022/05/31
- 02/11: gnu: quazip: Update to 1.3., guix-commits, 2022/05/31