Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH 2/4] attr: Make zlistattr return an array, zdelattr take several attrs
- X-seq: zsh-workers 27344
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: zsh workers <zsh-workers@xxxxxxx>
- Subject: [PATCH 2/4] attr: Make zlistattr return an array, zdelattr take several attrs
- Date: Tue, 3 Nov 2009 19:56:22 +0100 (CET)
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:subject :in-reply-to:message-id:references:user-agent:mime-version :content-type; bh=0jP0hHsoqjiwpS/DvmppXYxV7SHVZUKKTZ7imUmjyCw=; b=I03c5UzwWGfIvqNlU3jGTzCXEgS62S5X6I3wFpB/9AFMo0e0CAKiU1Oxz2TI1vs0uL sTDTpus5bA8WaQhznAJXHt/qrI2r2Vt+FDrT2II+uBdxUu5pfCo3XMRSsC1KHYbTHFyY vmHpyLEpdEKqv8gTtB5IrvrIDbD8ZKorgb2V8=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:subject:in-reply-to:message-id:references:user-agent :mime-version:content-type; b=IQHdVGmZkXIKpbXm5lfh7d1ySvy83MvXUnXgwtli3T/hMzKoJGHec7SPSGvbskmCGY +SB10e+lxyUdkPWX5JruDn2l4IkbCvOpr86FrMfm2Nf1TwO01HORhmHw0nyFzggduFkz Urf0SNaAdVLO2WYKIOtJvguC0DBErEQnaY5fk=
- In-reply-to: <alpine.LNX.2.00.0911031951480.3519@localhost>
- 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
- References: <alpine.LNX.2.00.0902262245590.27571@localhost> <20090303121253.61f5e2ec@news01> <alpine.LNX.2.00.0903031455360.10365@localhost> <20090303163526.533995be@news01> <237967ef0903030851gc26620ficfc908628a4b3be2@xxxxxxxxxxxxxx> <alpine.LNX.2.00.0911031951480.3519@localhost>
---
Completion/Zsh/Command/_zattr | 2 +-
Src/Modules/attr.c | 39 ++++++++++++++++++++++++++++++---------
2 files changed, 31 insertions(+), 10 deletions(-)
diff --git a/Completion/Zsh/Command/_zattr b/Completion/Zsh/Command/_zattr
index 55804db..a6ae806 100644
--- a/Completion/Zsh/Command/_zattr
+++ b/Completion/Zsh/Command/_zattr
@@ -31,6 +31,6 @@ esac
if [[ $state = attrs ]]; then
if [[ -f $~line[1] ]]; then
zlistattr $~line[1] REPLY
- _wanted attrs expl 'attribute' compadd ${(0)REPLY}
+ _wanted attrs expl 'attribute' compadd $REPLY
fi
fi
diff --git a/Src/Modules/attr.c b/Src/Modules/attr.c
index cbf3d92..1a9c323 100644
--- a/Src/Modules/attr.c
+++ b/Src/Modules/attr.c
@@ -142,12 +142,16 @@ bin_delattr(char *nam, char **argv, Options ops, UNUSED(int func))
{
int ret = 0, slen;
int symlink = OPT_ISSET(ops, 'h');
+ char *file = *argv;
- unmetafy(*argv, &slen);
- unmetafy(*(argv+1), NULL);
- if (xremovexattr(*argv, *(argv+1), symlink)) {
- zwarnnam(nam, "%s: %e", metafy(*argv, slen, META_NOALLOC), errno);
- ret = 1;
+ unmetafy(file, &slen);
+ while (*++argv) {
+ unmetafy(*argv, NULL);
+ if (xremovexattr(file, *argv, symlink)) {
+ zwarnnam(nam, "%s: %e", metafy(file, slen, META_NOALLOC), errno);
+ ret = 1;
+ break;
+ }
}
return ret;
}
@@ -164,9 +168,26 @@ bin_listattr(char *nam, char **argv, Options ops, UNUSED(int func))
if (0 < (len = xlistxattr(*argv, value, 256, symlink))) {
if (len < 256) {
char *p = value;
- if (*(argv+1))
- setsparam(*(argv+1), metafy(value, len, META_DUP));
- else while (p < &value[len]) {
+ if (*(argv+1)) {
+ if (strlen(value) + 1 == len)
+ setsparam(*(argv+1), metafy(value, len-1, META_DUP));
+ else {
+ int arrlen = 0;
+ char **array = NULL, **arrptr = NULL;
+
+ while (p < &value[len]) {
+ arrlen++;
+ p += strlen(p) + 1;
+ }
+ arrptr = array = (char **)zshcalloc((arrlen+1) * sizeof(char *));
+ p = value;
+ while (p < &value[len]) {
+ *arrptr++ = metafy(p, -1, META_DUP);
+ p += strlen(p) + 1;
+ }
+ setaparam(*(argv+1), array);
+ }
+ } else while (p < &value[len]) {
printf("%s\n", p);
p += strlen(p) + 1;
}
@@ -183,7 +204,7 @@ bin_listattr(char *nam, char **argv, Options ops, UNUSED(int func))
static struct builtin bintab[] = {
BUILTIN("zgetattr", 0, bin_getattr, 2, 3, 0, "h", NULL),
BUILTIN("zsetattr", 0, bin_setattr, 3, 3, 0, "h", NULL),
- BUILTIN("zdelattr", 0, bin_delattr, 2, 2, 0, "h", NULL),
+ BUILTIN("zdelattr", 0, bin_delattr, 2, -1, 0, "h", NULL),
BUILTIN("zlistattr", 0, bin_listattr, 1, 2, 0, "h", NULL),
};
--
1.6.5
Messages sorted by:
Reverse Date,
Date,
Thread,
Author