Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: "does not contain a file descriptor" (Re: cat as a builtin command)
On Sep 2, 9:43am, Peter Stephenson wrote:
}
} On Mon, 01 Sep 2014 12:44:03 -0700
} Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
}
} > I won't commit this without getting feedback, because it doesn't work
} > correctly with parameters declared as integers in bases other than 10
}
} I don't think this problem's fatal, but it's surprising if there isn't
} some way or other of getting this to work by indicating the base
} appropriately.
Hm. How about this, then?
diff --git a/Src/exec.c b/Src/exec.c
index bf50d0f..fb2739a 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -3050,7 +3050,7 @@ execcmd(Estate state, int input, int output, int how, int last1)
break;
case REDIR_CLOSE:
if (fn->varid) {
- char *s = fn->varid;
+ char *s = fn->varid, *t;
struct value vbuf;
Value v;
int bad = 0;
@@ -3060,13 +3060,25 @@ execcmd(Estate state, int input, int output, int how, int last1)
} else if (v->pm->node.flags & PM_READONLY) {
bad = 2;
} else {
- fn->fd1 = (int)getintvalue(v);
+ s = getstrvalue(v);
if (errflag)
bad = 1;
- else if (fn->fd1 <= max_zsh_fd) {
- if (fn->fd1 >= 10 &&
- fdtable[fn->fd1] == FDT_INTERNAL)
- bad = 3;
+ else {
+ fn->fd1 = zstrtol(s, &t, 0);
+ if (s == t)
+ bad = 1;
+ else if (*t) {
+ /* Check for base#number format */
+ if (*t == '#' && *s != '0')
+ fn->fd1 = zstrtol(s = t+1, &t, fn->fd1);
+ if (s == t || *t)
+ bad = 1;
+ }
+ if (!bad && fn->fd1 <= max_zsh_fd) {
+ if (fn->fd1 >= 10 &&
+ fdtable[fn->fd1] == FDT_INTERNAL)
+ bad = 3;
+ }
}
}
if (bad) {
--
Barton E. Schaefer
Messages sorted by:
Reverse Date,
Date,
Thread,
Author