* Bug path completion chsh -s
@ 2014-08-21 22:40 qcd
2014-08-23 4:08 ` Bart Schaefer
0 siblings, 1 reply; 5+ messages in thread
From: qcd @ 2014-08-21 22:40 UTC (permalink / raw)
To: zsh-workers
[-- Attachment #1: Type: text/plain, Size: 172 bytes --]
Bug:
path completion does not work for chsh -s in zsh.
> chsh -s <tab>
in normal shellproposes a path list but in zsh that does not work.
please fix.
sincerely
qcd
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Bug path completion chsh -s
2014-08-21 22:40 Bug path completion chsh -s qcd
@ 2014-08-23 4:08 ` Bart Schaefer
2014-08-23 19:31 ` Bart Schaefer
2014-08-24 4:38 ` Mikael Magnusson
0 siblings, 2 replies; 5+ messages in thread
From: Bart Schaefer @ 2014-08-23 4:08 UTC (permalink / raw)
To: qcd, zsh-workers
On Aug 22, 12:40am, qcd wrote:
}
} > chsh -s <tab>
}
} in normal shellproposes a path list but in zsh that does not work.
What is "normal shell"? Bash? What version? Are you on a single-user
system you set up yourself, or are you at a school or business where an
administrator has pre-configured the "normal shell"?
Also, chsh has different syntax on different OS's: On MacOS it's an
alias for chpass; on Ubuntu it only has --help and --shell options
(and their -h -s counterparts); on RHEL it has several options and
uses -u instead of -h for --help, and adds -l for --list, both of
which conflict with chpass on MacOs; and so on. So "please fix" is
a rather open-ended request.
Oh well, never mind. Here's something for RHEL; perhaps you can figure
out how to fix it for your local environment, or just remove everything
except -s, given that's the one thing they all seem to have in common.
---- 8< ---- name this _chsh and put in an fpath directory ---- 8< ----
#compdef chsh
local -a opts
opts=(-s -l -u -v --shell --list-shells --help --version)
_arguments : \
"($opts)-s[Specify your login shell]:shell:($(</etc/shells))" \
"($opts)--shell[Specify your login shell]:shell:($(</etc/shells))" \
"($opts)-l[Print shells in /etc/shells]" \
"($opts)--list-shells[Print shells in /etc/shells]" \
"($opts)-u[Print a usage message and exit]" \
"($opts)--help[Print a usage message and exit]" \
"($opts)-v[Print version information and exit]" \
"($opts)--version[Print version information and exit]"
---- 8< ---- snip ---- 8< ---- -------- ---- 8< ---- snip ---- 8< ----
Maybe somebody else can remind me if there's an easier way to indicate
to _arguments that all the arguments are mutually exclusive. (RedHat
chsh accepts more than one but only uses the first one it encounters.)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Bug path completion chsh -s
2014-08-23 4:08 ` Bart Schaefer
@ 2014-08-23 19:31 ` Bart Schaefer
2014-08-25 15:37 ` Jun T.
2014-08-24 4:38 ` Mikael Magnusson
1 sibling, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2014-08-23 19:31 UTC (permalink / raw)
To: zsh-workers
On Aug 22, 9:08pm, Bart Schaefer wrote:
}
} Also, chsh has different syntax on different OS's: On MacOS it's an
} alias for chpass; on Ubuntu it only has --help and --shell options
} (and their -h -s counterparts); on RHEL it has several options and
} uses -u instead of -h for --help, and adds -l for --list, both of
} which conflict with chpass on MacOs; and so on. So "please fix" is
} a rather open-ended request.
Having done that research, I went ahead and created an _chsh that I
think covers most cases. I don't have BSD handy to test with, but the
man page on MacOS claims it is using the BSD chpass.
} Maybe somebody else can remind me if there's an easier way to indicate
} to _arguments that all the arguments are mutually exclusive.
Of course there is, it's just (-).
diff --git a/Completion/Unix/Command/.distfiles b/Completion/Unix/Command/.distfiles
index fe810e1..35d81b2 100644
--- a/Completion/Unix/Command/.distfiles
+++ b/Completion/Unix/Command/.distfiles
@@ -29,6 +29,7 @@ _cdrecord
_chkconfig
_chmod
_chown
+_chsh
_clay
_comm
_compress
diff --git a/Completion/Unix/Command/_chsh b/Completion/Unix/Command/_chsh
new file mode 100644
index 0000000..97552e3
--- /dev/null
+++ b/Completion/Unix/Command/_chsh
@@ -0,0 +1,40 @@
+#compdef chsh chpass
+case $OSTYPE in
+(darwin*|*bsd*)
+ _arguments : \
+ '-s[Specify user login shell]:shell:(${(Z+Cn+)"$(</etc/shells)"})' \
+ "-l[Specify location of user]:node:" \
+ "-u[Specify authentication name]:auth user:" \
+ "1:user name:_users"
+ ;;
+(linux-gnu)
+ if { =chsh -v } >&/dev/null
+ then
+ local -a opts shells
+ shells=( $(=chsh -l) )
+ _arguments : \
+ "(-)-s[Specify your login shell]:shell:($shells)" \
+ "(-)--shell[Specify your login shell]:shell:($shells)" \
+ "(-)-l[Print shells in /etc/shells]" \
+ "(-)--list-shells[Print shells in /etc/shells]" \
+ "(-)-u[Print a usage message and exit]" \
+ "(-)--help[Print a usage message and exit]" \
+ "(-)-v[Print version information and exit]" \
+ "(-)--version[Print version information and exit]" \
+ "1:user name:_users"
+ return
+ fi
+ # else fall through
+ ;&
+(*)
+ local s=''
+ # Use $s to cause all options to be treated as mutually exclusive
+ [[ $words[CURRENT-1] = -* ]] && s="(-)$words[CURRENT-1]"
+ # This fiddling with $s is a hack to cause "_arguments : --" to use
+ # the /etc/shells listing for -s or --shell even when the description
+ # of that option has been pulled from the GNU --help output.
+ [[ $words[CURRENT-1] = (-s|--shell) ]] &&
+ s="$s"'[ ]:shell:(${(Z+Cn+)"$(</etc/shells)"})'
+ _arguments : $s "1:user name:_users" --
+ ;;
+esac
diff --git a/Completion/Unix/Type/_users b/Completion/Unix/Type/_users
index 5ab8dbc..3c8c702 100644
--- a/Completion/Unix/Type/_users
+++ b/Completion/Unix/Type/_users
@@ -1,4 +1,4 @@
-#compdef passwd groups userdel chage chfn chsh
+#compdef passwd groups userdel chage chfn
local expl users
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Bug path completion chsh -s
2014-08-23 4:08 ` Bart Schaefer
2014-08-23 19:31 ` Bart Schaefer
@ 2014-08-24 4:38 ` Mikael Magnusson
1 sibling, 0 replies; 5+ messages in thread
From: Mikael Magnusson @ 2014-08-24 4:38 UTC (permalink / raw)
To: Bart Schaefer; +Cc: qcd, zsh workers
On 23 August 2014 06:08, Bart Schaefer <schaefer@brasslantern.com> wrote:
> On Aug 22, 12:40am, qcd wrote:
> }
> } > chsh -s <tab>
> }
> } in normal shellproposes a path list but in zsh that does not work.
>
> What is "normal shell"? Bash? What version? Are you on a single-user
> system you set up yourself, or are you at a school or business where an
> administrator has pre-configured the "normal shell"?
>
> Also, chsh has different syntax on different OS's: On MacOS it's an
> alias for chpass; on Ubuntu it only has --help and --shell options
> (and their -h -s counterparts); on RHEL it has several options and
> uses -u instead of -h for --help, and adds -l for --list, both of
> which conflict with chpass on MacOs; and so on. So "please fix" is
> a rather open-ended request.
>
> Oh well, never mind. Here's something for RHEL; perhaps you can figure
> out how to fix it for your local environment, or just remove everything
> except -s, given that's the one thing they all seem to have in common.
>
> ---- 8< ---- name this _chsh and put in an fpath directory ---- 8< ----
> #compdef chsh
> local -a opts
> opts=(-s -l -u -v --shell --list-shells --help --version)
> _arguments : \
> "($opts)-s[Specify your login shell]:shell:($(</etc/shells))" \
> "($opts)--shell[Specify your login shell]:shell:($(</etc/shells))" \
> "($opts)-l[Print shells in /etc/shells]" \
> "($opts)--list-shells[Print shells in /etc/shells]" \
> "($opts)-u[Print a usage message and exit]" \
> "($opts)--help[Print a usage message and exit]" \
> "($opts)-v[Print version information and exit]" \
> "($opts)--version[Print version information and exit]"
> ---- 8< ---- snip ---- 8< ---- -------- ---- 8< ---- snip ---- 8< ----
>
> Maybe somebody else can remind me if there's an easier way to indicate
> to _arguments that all the arguments are mutually exclusive. (RedHat
> chsh accepts more than one but only uses the first one it encounters.)
chsh is listed on the compdef line of _users, so you need to remove
that as well. (maybe not since c comes before u, but we still should
remove it if this is committed).
--
Mikael Magnusson
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Bug path completion chsh -s
2014-08-23 19:31 ` Bart Schaefer
@ 2014-08-25 15:37 ` Jun T.
0 siblings, 0 replies; 5+ messages in thread
From: Jun T. @ 2014-08-25 15:37 UTC (permalink / raw)
To: zsh-workers
2014/08/24 04:31, Bart Schaefer <schaefer@brasslantern.com> wrote:
> I don't have BSD handy to test with, but the
> man page on MacOS claims it is using the BSD chpass.
It seems BSDs have different options than Darwin.
I only have FreeBSD, but checked the manpages of {Open|Net}BSD and
Dragonfly on their websites. The options are different among them,
so I only added options common to them.
I also removed Capitalization from the descriptions of options
(Specify --> specify, etc.).
diff --git a/Completion/Unix/Command/_chsh b/Completion/Unix/Command/_chsh
index 97552e3..4f6453e 100644
--- a/Completion/Unix/Command/_chsh
+++ b/Completion/Unix/Command/_chsh
@@ -1,26 +1,35 @@
#compdef chsh chpass
case $OSTYPE in
-(darwin*|*bsd*)
+(darwin*)
_arguments : \
- '-s[Specify user login shell]:shell:(${(Z+Cn+)"$(</etc/shells)"})' \
- "-l[Specify location of user]:node:" \
- "-u[Specify authentication name]:auth user:" \
+ '-s[specify user login shell]:shell:(${(Z+Cn+)"$(</etc/shells)"})' \
+ "-l[specify location of user]:node:" \
+ "-u[specify authentication name]:auth user:" \
"1:user name:_users"
;;
+(*bsd*|dragonfly*)
+ # options common to most BSD flavors
+ _arguments : \
+ '(-a)-s[specify user login shell]:shell:(${(Z+Cn+)"$(</etc/shells)"})' \
+ '(-s)-a[passwd file entry]:colon-separated list:' \
+ '(-y)-l[change local password database]' \
+ '(-l)-y[change YP(NIS) password database]' \
+ '1:user name:_users'
+ ;;
(linux-gnu)
if { =chsh -v } >&/dev/null
then
local -a opts shells
shells=( $(=chsh -l) )
_arguments : \
- "(-)-s[Specify your login shell]:shell:($shells)" \
- "(-)--shell[Specify your login shell]:shell:($shells)" \
- "(-)-l[Print shells in /etc/shells]" \
- "(-)--list-shells[Print shells in /etc/shells]" \
- "(-)-u[Print a usage message and exit]" \
- "(-)--help[Print a usage message and exit]" \
- "(-)-v[Print version information and exit]" \
- "(-)--version[Print version information and exit]" \
+ "(-)-s[specify your login shell]:shell:($shells)" \
+ "(-)--shell[specify your login shell]:shell:($shells)" \
+ "(-)-l[print shells in /etc/shells]" \
+ "(-)--list-shells[print shells in /etc/shells]" \
+ "(-)-u[print a usage message and exit]" \
+ "(-)--help[print a usage message and exit]" \
+ "(-)-v[print version information and exit]" \
+ "(-)--version[print version information and exit]" \
"1:user name:_users"
return
fi
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-08-25 16:15 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-21 22:40 Bug path completion chsh -s qcd
2014-08-23 4:08 ` Bart Schaefer
2014-08-23 19:31 ` Bart Schaefer
2014-08-25 15:37 ` Jun T.
2014-08-24 4:38 ` Mikael Magnusson
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).