* [PATCH 1/2] _mkdir: Don't offer a linux-specific optiont in the 'zsh' variant.
@ 2017-08-29 2:28 Daniel Shahaf
2017-08-29 2:28 ` [PATCH 2/2] _mkdir: Honour the 'command' and 'builtin' precommand modifiers Daniel Shahaf
2017-08-29 11:06 ` [PATCH 1/2] _mkdir: Don't offer a linux-specific optiont in the 'zsh' variant Oliver Kiddle
0 siblings, 2 replies; 4+ messages in thread
From: Daniel Shahaf @ 2017-08-29 2:28 UTC (permalink / raw)
To: zsh-workers
---
Completion/Unix/Command/_mkdir | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/Completion/Unix/Command/_mkdir b/Completion/Unix/Command/_mkdir
index f2299f7c7..b104d3d60 100644
--- a/Completion/Unix/Command/_mkdir
+++ b/Completion/Unix/Command/_mkdir
@@ -9,14 +9,6 @@ args=(
'(-)*: :->directories'
)
-case "$OSTYPE" in
- linux*)
- args+=(
- '(-Z --context)'{-Z,--context=}'[set SELinux context]:SELinux context'
- )
- ;;
-esac
-
_pick_variant -r variant gnu=gnu zsh='\(eval\)' $OSTYPE --help
# It can still happen that there is a precommand command or builtin in the line.
# In such cases, the variant has to be modified suitably, after further checking
@@ -42,12 +34,12 @@ case $variant in
;|
gnu)
args+=(
+ '(-Z --context)'{-Z,--context=}'[set SELinux context]:SELinux context'
'(- :)--help[display help information]'
'(- :)--version[display version information]'
)
;;
zsh) # remove all options
- args=( '*: :->directories' )
;;
*) # non-GNU: remove long options
args=( ${${${args:#(|*\))--*}//--[^ )]#/}/\( #\)/} )
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] _mkdir: Honour the 'command' and 'builtin' precommand modifiers.
2017-08-29 2:28 [PATCH 1/2] _mkdir: Don't offer a linux-specific optiont in the 'zsh' variant Daniel Shahaf
@ 2017-08-29 2:28 ` Daniel Shahaf
2017-08-29 11:06 ` [PATCH 1/2] _mkdir: Don't offer a linux-specific optiont in the 'zsh' variant Oliver Kiddle
1 sibling, 0 replies; 4+ messages in thread
From: Daniel Shahaf @ 2017-08-29 2:28 UTC (permalink / raw)
To: zsh-workers
---
Hi,
This patch implements the "once a way is found out" comment that it removes.
It works correctly on linux:
% mkdir <TAB>
DEBUG: variant=gnu
% zmodload zsh/files
% mkdir <TAB>
DEBUG: variant=zsh
... but it would be good if someone could confirm that it still works on
$OSTYPE == (freebsd|dragonfly)* as well: the code special-cases those
$OSTYPE's.
Thanks,
Daniel
Completion/Unix/Command/_mkdir | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/Completion/Unix/Command/_mkdir b/Completion/Unix/Command/_mkdir
index b104d3d60..7e8ff121a 100644
--- a/Completion/Unix/Command/_mkdir
+++ b/Completion/Unix/Command/_mkdir
@@ -9,22 +9,21 @@ args=(
'(-)*: :->directories'
)
-_pick_variant -r variant gnu=gnu zsh='\(eval\)' $OSTYPE --help
# It can still happen that there is a precommand command or builtin in the line.
# In such cases, the variant has to be modified suitably, after further checking
# the variant of the _command_ mkdir.
-
-# I currently don't know of any way to find out what precommands are present on
-# the line. The variant should be modified like this once a way is found out:
-
-# if [[ $variant == zsh ]]; then
-# if [[ $precommand = *command* ]]; then
-# _mkdir_command () { command mkdir "$@" }
-# _pick_variant -c _mkdir_command -r variant gnu=gnu unix --help
-# fi
-# elif [[ $precommand = *builtin* ]]; then
-# variant=zsh
-# fi
+#
+# $precommands is defined in _main_complete
+if (( ${+precommands[(r)command]} )); then
+ _mkdir_command () { command mkdir "$@" }
+ _pick_variant -c _mkdir_command -r variant gnu=gnu unix --help
+ unfunction _mkdir_command
+elif (( ${+precommands[(r)builtin]} )) || (( ${+builtins[mkdir]} )) || [[ "$(type -w mkdir)" == "*: builtin" ]]; then
+ variant=zsh
+else
+ _pick_variant -r variant gnu=gnu zsh='\(eval\)' $OSTYPE --help
+fi
+# Now $variant is set.
case $variant in
gnu|freebsd*|dragonfly*)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] _mkdir: Don't offer a linux-specific optiont in the 'zsh' variant.
2017-08-29 2:28 [PATCH 1/2] _mkdir: Don't offer a linux-specific optiont in the 'zsh' variant Daniel Shahaf
2017-08-29 2:28 ` [PATCH 2/2] _mkdir: Honour the 'command' and 'builtin' precommand modifiers Daniel Shahaf
@ 2017-08-29 11:06 ` Oliver Kiddle
2017-08-30 0:19 ` Daniel Shahaf
1 sibling, 1 reply; 4+ messages in thread
From: Oliver Kiddle @ 2017-08-29 11:06 UTC (permalink / raw)
To: Daniel Shahaf; +Cc: zsh-workers
Daniel Shahaf wrote:
> gnu)
> args+=(
> + '(-Z --context)'{-Z,--context=}'[set SELinux context]:SELinux context'
That now offers -Z for people using GNU mkdir on a non-Linux system.
That's far from unusual, either via g prefixes, e.g. gmkdir, aliases or
directories like /usr/gnu/bin. We could perhaps change the case statement
to check both variables - case $variant:$OSTYPE - to allow a match for
gnu:linux*.
Oliver
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] _mkdir: Don't offer a linux-specific optiont in the 'zsh' variant.
2017-08-29 11:06 ` [PATCH 1/2] _mkdir: Don't offer a linux-specific optiont in the 'zsh' variant Oliver Kiddle
@ 2017-08-30 0:19 ` Daniel Shahaf
0 siblings, 0 replies; 4+ messages in thread
From: Daniel Shahaf @ 2017-08-30 0:19 UTC (permalink / raw)
To: zsh-workers
Oliver Kiddle wrote on Tue, 29 Aug 2017 13:06 +0200:
> Daniel Shahaf wrote:
> > gnu)
> > args+=(
> > + '(-Z --context)'{-Z,--context=}'[set SELinux context]:SELinux context'
>
> That now offers -Z for people using GNU mkdir on a non-Linux system.
> That's far from unusual, either via g prefixes, e.g. gmkdir, aliases or
> directories like /usr/gnu/bin. We could perhaps change the case statement
> to check both variables - case $variant:$OSTYPE - to allow a match for
> gnu:linux*.
Good catch. I'll add an if [[ $OSTYPE == linux* ]] to the case block.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-08-30 0:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-29 2:28 [PATCH 1/2] _mkdir: Don't offer a linux-specific optiont in the 'zsh' variant Daniel Shahaf
2017-08-29 2:28 ` [PATCH 2/2] _mkdir: Honour the 'command' and 'builtin' precommand modifiers Daniel Shahaf
2017-08-29 11:06 ` [PATCH 1/2] _mkdir: Don't offer a linux-specific optiont in the 'zsh' variant Oliver Kiddle
2017-08-30 0:19 ` Daniel Shahaf
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).