* [PATCH] _mdadm completion: make mdadm.conf config file usage more flexible
@ 2012-04-16 12:11 Michael Prokop
0 siblings, 0 replies; only message in thread
From: Michael Prokop @ 2012-04-16 12:11 UTC (permalink / raw)
To: zsh-workers; +Cc: Michael Prokop
From: Michael Prokop <mika@debian.org>
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2012-04-16 12:21 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-16 12:11 [PATCH] _mdadm completion: make mdadm.conf config file usage more flexible Michael Prokop
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).