Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] _mdadm completion: make mdadm.conf config file usage more flexible
- X-seq: zsh-workers 30414
- From: Michael Prokop <news@xxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] _mdadm completion: make mdadm.conf config file usage more flexible
- Date: Mon, 16 Apr 2012 14:11:26 +0200
- Cc: Michael Prokop <mika@xxxxxxxxxx>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
From: Michael Prokop <mika@xxxxxxxxxx>
For example Debian uses /etc/mdadm/mdadm.conf as its
configuration file, whereas some other distributions use
/etc/mdadm.conf. Therefore check for presence of /etc/mdadm.conf
and /etc/mdadm/mdadm.conf and if neither of them is useable
provide an error message to the user instead of failing with just
'_mds:2: no such file or directory: /etc/mdadm.conf'
---
Completion/Linux/Command/_mdadm | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/Completion/Linux/Command/_mdadm b/Completion/Linux/Command/_mdadm
index 461e666..940eb68 100644
--- a/Completion/Linux/Command/_mdadm
+++ b/Completion/Linux/Command/_mdadm
@@ -147,7 +147,15 @@ fi
_mds () {
local -a vals
- vals=( ${${${(M)${(f)"$(< /etc/mdadm.conf)"}##ARRAY *}//ARRAY /}%%[[:blank:]]*} )
+ if [ -r /etc/mdadm.conf ] ; then
+ local mdadm_conf=/etc/mdadm.conf
+ elif [ -r /etc/mdadm/mdadm.conf ] ; then
+ local mdadm_conf=/etc/mdadm/mdadm.conf
+ else
+ _message "could not find mdadm.conf"
+ return 1
+ fi
+ vals=( ${${${(M)${(f)"$(< $mdadm_conf)"}##ARRAY *}//ARRAY /}%%[[:blank:]]*} )
_describe -t mds "RAID devices" vals
_arguments \
"(-h --help)"{-h,--help}'[display a mode specific help message]'
--
1.7.9.1
Messages sorted by:
Reverse Date,
Date,
Thread,
Author