* Re: PATCH: _tar, again
@ 1999-03-09 11:16 Sven Wischnowsky
0 siblings, 0 replies; 2+ messages in thread
From: Sven Wischnowsky @ 1999-03-09 11:16 UTC (permalink / raw)
To: zsh-workers
Peter Stephenson wrote:
> Minor gripes: in the listing, _long_options doesn't show the / after
> directories inside the archive as my original _tar did (that's why I stuck
> it on the end instead of treating it as a suffix);
I was aware of this, I just thought that the auto-removability was
more interesting. But if you prefer... the patch below changes this.
> _path_files seems to
> have forgotten about noglobdots somehow.
Actually `globdots' was explicitly set, I don't remember why, so the
patch removes the setopts for it.
> Somehow my _match_pattern isn't
> having an effect on _multi_parts, but I suppose that's my problem.
*Shrug*, works for me...
Bye
Sven
diff -u oc/Core/_main_complete Completion/Core/_main_complete
--- oc/Core/_main_complete Tue Mar 9 11:31:45 1999
+++ Completion/Core/_main_complete Tue Mar 9 11:49:11 1999
@@ -32,7 +32,7 @@
local comp name _comp_correct comax
-setopt localoptions nullglob rcexpandparam globdots
+setopt localoptions nullglob rcexpandparam
unsetopt markdirs globsubst shwordsplit nounset ksharrays
# Special completion contexts after `~' and `='.
diff -u oc/Core/_multi_parts Completion/Core/_multi_parts
--- oc/Core/_multi_parts Tue Mar 9 11:31:45 1999
+++ Completion/Core/_multi_parts Tue Mar 9 12:10:34 1999
@@ -143,7 +143,7 @@
for i in "$matches[@]" ; do
if [[ "$i" = *${sep}* ]]; then
compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" \
- -p "$pref" -qS "$sep" -s "$orig" - "${i%%${sep}*}"
+ -p "$pref" -s "$orig" - "${i%%${sep}*}${sep}"
else
compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" \
-p "$pref" -s "$orig" - "${i%%${sep}*}"
@@ -152,8 +152,8 @@
else
for i in "$matches[@]" ; do
if [[ "$i" = *${sep}* ]]; then
- compadd -U -i "$IPREFIX" -p "$pref" -s "${sep}${i#*${sep}}" \
- "$group[@]" "$expl[@]" -M "r:|${sep:q}=*" - "${i%%${sep}*}"
+ compadd -U -i "$IPREFIX" -p "$pref" -s "${i#*${sep}}" \
+ "$group[@]" "$expl[@]" -M "r:|${sep:q}=*" - "${i%%${sep}*}${sep}"
else
compadd -U "$group[@]" "$expl[@]" -i "$IPREFIX" -p "$pref" - "$i"
fi
diff -u oc/Core/_path_files Completion/Core/_path_files
--- oc/Core/_path_files Tue Mar 9 11:31:45 1999
+++ Completion/Core/_path_files Tue Mar 9 11:49:15 1999
@@ -22,7 +22,7 @@
local tmp1 collect tmp2 suffixes i ignore matchflags opt group sopt pats gopt
local addpfx addsfx expl orig ostr nm=$compstate[nmatches] menu
-setopt localoptions nullglob rcexpandparam globdots extendedglob
+setopt localoptions nullglob rcexpandparam extendedglob
unsetopt markdirs globsubst shwordsplit nounset
prepaths=('')
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] 2+ messages in thread
* PATCH: _tar, again
1999-03-08 11:15 PATCH: _long_options Peter Stephenson
@ 1999-03-08 14:27 ` Peter Stephenson
0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 1999-03-08 14:27 UTC (permalink / raw)
To: zsh-workers
Peter Stephenson wrote:
> - in principle, you can have combined short arguments like -xv or -cP or
> whatever anywhere on the command line before the file list, so it probably
> ought to check if it had no luck early on --- e.g. look for
> -[[:alpha:]]#[cxturA]*
actually, this was pretty much handled and I didn't notice.
> - any --use-compress-program=*, or indeed --use-comp*, should get added to
> $largs
>
> - any --dir*=* should be changed to when completing archives and existing
> files, which is another good argument for using absolute paths for $tf.
actually, this should only be done for putting files inside the archive,
not for the archive itself.
This handles these and fixes some bugs: finding the archive didn't work if
there were --*'s because it miscounted words; the files inside the archive
were used even for creating an archive (if that was deliberate, there are
probably better ways of persuading the user not to overwrite an existing
archive).
Minor gripes: in the listing, _long_options doesn't show the / after
directories inside the archive as my original _tar did (that's why I stuck
it on the end instead of treating it as a suffix); _path_files seems to
have forgotten about noglobdots somehow. Somehow my _match_pattern isn't
having an effect on _multi_parts, but I suppose that's my problem.
--- ./Completion/User/_tar.bak Mon Mar 8 14:59:18 1999
+++ ./Completion/User/_tar Mon Mar 8 15:24:06 1999
@@ -16,7 +16,7 @@
emulate -LR zsh
setopt extendedglob
-local _tar_cmd tf tmp
+local _tar_cmd tf tmp del
# First we collect in `_tar_cmd' single letter options describing what
# should be done with the archive and if it is compressed. This
@@ -32,7 +32,19 @@
(( $words[(I)--list] )) && _tar_cmd="t$_tar_cmd"
(( $words[(I)--(extract|get)] )) && _tar_cmd="x$_tar_cmd"
(( $words[(I)--create] )) && _tar_cmd="c$_tar_cmd"
-[[ "$words[2]" != -* ]] && _tar_cmd="$words[2]$_tar_cmd"
+
+# Other ways of finding out what we're doing: first
+# look in the first argument if it's not an option
+if [[ "$words[2]" = *[txcdruA]*~-* ]]; then
+ _tar_cmd="$words[2]$_tar_cmd"
+elif [[ $_tar_cmd != *[txcdruA]* && CURRENT -gt 2 ]]; then
+ # look for more obscure long options: these aren't all handled.
+ (( $words[(I)--(diff|compare)] )) && _tar_cmd="d$_tar_cmd"
+ (( $words[(I)--append] )) && _tar_cmd="r$_tar_cmd"
+ (( $words[(I)--update] )) && _tar_cmd="u$_tar_cmd"
+ (( $words[(I)--(con|)catenate] )) && _tar_cmd="A$_tar_cmd"
+ (( $words[(I)--delete] )) && del=1
+fi
# Next, we try to find the archive name and store it in `tf'. The name
# is searched after a `--file=' long option, in the third word if the
@@ -47,7 +59,7 @@
tf="$words[3]"
_tar_cmd="f$_tar_cmd"
else
- tmp="${${(@M)words:#-[^-]*}[(I)*f*]}"
+ tmp="${words[(I)-*f*~--*]}"
if (( tmp )); then
tf="$words[tmp+1]"
_tar_cmd="f$_tar_cmd"
@@ -73,7 +85,7 @@
_tar_archive
-elif [[ -n "$_tar_cmd" && -n "$tf" ]]; then
+elif [[ ( "$_tar_cmd" = *[xt]* || -n $del ) && -n "$tf" ]]; then
# ...and files from the archive if we found an archive name and tar
# commands. We run `tar t...' on the file, keeping the list of
@@ -82,8 +94,15 @@
local largs=-tf
- [[ $_tar_cmd = *z* ]] && largs=-tzf
- [[ $_tar_cmd = *Z* ]] && largs=-tZf
+ if [[ $_tar_cmd = *z* ]]; then
+ largs=-tzf
+ elif [[ $_tar_cmd = *Z* ]]; then
+ largs=-tZf
+ else
+ # Some random compression program e.g. bzip2
+ tmp="${words[(r)--use-comp*]}"
+ [[ -n $tmp ]] && largs=($tmp -tf)
+ fi
if [[ $tf != $_tar_cache_name ]]; then
_tar_cache_list=("${(@f)$($words[1] $largs $tf)}")
@@ -91,4 +110,16 @@
fi
_multi_parts / _tar_cache_list
+else
+
+ # See if we should use a path prefix. We have to use eval as the dir can
+ # be any unevaluated thing which appears on the command line, including a
+ # parameter.
+ tmp=${words[(r)--dir[a-z]#=*]}
+ if [[ -n $tmp ]]; then
+ eval "tmp=(${tmp#*=})"
+ _path_files -W tmp
+ else
+ _files
+ fi
fi
--
Peter Stephenson <pws@ibmth.df.unipi.it> Tel: +39 050 844536
WWW: http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1999-03-09 11:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-03-09 11:16 PATCH: _tar, again Sven Wischnowsky
-- strict thread matches above, loose matches on Subject: below --
1999-03-08 11:15 PATCH: _long_options Peter Stephenson
1999-03-08 14:27 ` PATCH: _tar, again Peter Stephenson
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).