Re: ksh history bug
On Wed, Aug 13, 2014 at 07:41:08PM +0100, Jason McIntyre wrote: the only thing i have to compare it with is bash: By no means comprehensive but: these appear to not include the current command: zsh FreeBSD ash these appear to include the current command: ATT ksh bash csh tcsh From pdksh ChangeLog: Tue May 7 10:11:41 NDT 1996 Michael Rendell (mich...@panda.cs.mun.ca) * history.c(hist_get_newest,hist_get_oldest): don't find the current (fc) command; removed print_err argument (was always true). I am unable to find old pdksh sources to see if this patch is any better... Index: history.c === RCS file: /cvs/src/bin/ksh/history.c,v retrieving revision 1.39 diff -u -p -r1.39 history.c --- history.c 19 May 2010 17:36:08 - 1.39 +++ history.c 14 Aug 2014 15:43:38 - @@ -162,7 +162,7 @@ c_fc(char **wp) if (!hfirst) return 1; /* can't fail if hfirst didn't fail */ - hlast = hist_get_newest(false); + hlast = hist_get_newest(true); } else { /* POSIX says not an error if first/last out of bounds * when range is specified; att ksh and pdksh allow out of @@ -173,7 +173,7 @@ c_fc(char **wp) if (!hfirst) return 1; hlast = last ? hist_get(last, true, lflag ? true : false) : - (lflag ? hist_get_newest(false) : hfirst); + (lflag ? hist_get_newest(true) : hfirst); if (!hlast) return 1; }
ssh man page additions for unix domain socket forwarding
It might be desired to change some of the usage strings as well. Index: ssh.1 === RCS file: /cvs/src/usr.bin/ssh/ssh.1,v retrieving revision 1.348 diff -u -p -r1.348 ssh.1 --- ssh.1 24 Jul 2014 22:57:10 - 1.348 +++ ssh.1 13 Aug 2014 04:42:30 - @@ -307,7 +307,9 @@ made to port .Ar hostport from the remote machine. -Port forwardings can also be specified in the configuration file. +.Pp +Port forwardings can also be specified in the configuration file +.Pq see Cm LocalForward . IPv6 addresses can be specified by enclosing the address in square brackets. Only the superuser can forward privileged ports. By default, the local port is bound in accordance with the @@ -324,6 +326,11 @@ indicates that the listening port be bou empty address or .Sq * indicates that the port should be available from all interfaces. +.Pp +The local and/or remote forward endpoints may also be +.Xr unix 4 +domain sockets by specifying a pathname (that must contain at least +one slash character) in place of the hostname and port. .It Fl l Ar login_name Specifies the user to log in as on the remote machine. This also may be specified on a per-host basis in the configuration file. @@ -522,7 +529,8 @@ port .Ar hostport from the local machine. .Pp -Port forwardings can also be specified in the configuration file. +Port forwardings can also be specified in the configuration file +.Pq see Cm RemoteForward . Privileged ports can be forwarded only when logging in as root on the remote machine. IPv6 addresses can be specified by enclosing the address in square brackets. @@ -552,6 +560,11 @@ to the client at run time. When used together with .Ic -O forward the allocated port will be printed to the standard output. +.Pp +The local and/or remote forward endpoints may also be +.Xr unix 4 +domain sockets by specifying a pathname (that must contain at least +one slash character) in place of the hostname and port. .It Fl S Ar ctl_path Specifies the location of a control socket for connection sharing, or the string Index: ssh_config.5 === RCS file: /cvs/src/usr.bin/ssh/ssh_config.5,v retrieving revision 1.191 diff -u -p -r1.191 ssh_config.5 --- ssh_config.515 Jul 2014 15:54:14 - 1.191 +++ ssh_config.513 Aug 2014 04:42:30 - @@ -981,6 +988,11 @@ indicates that the listening port be bou empty address or .Sq * indicates that the port should be available from all interfaces. +.Pp +The local and/or remote forward endpoints may also be +.Xr unix 4 +domain sockets by specifying a pathname (that must contain at least +one slash character) in place of the hostname and port. .It Cm LogLevel Gives the verbosity level that is used when logging messages from .Xr ssh 1 . @@ -1204,6 +1216,11 @@ will only succeed if the server's .Cm GatewayPorts option is enabled (see .Xr sshd_config 5 ) . +.Pp +The local and/or remote forward endpoints may also be +.Xr unix 4 +domain sockets by specifying a pathname (that must contain at least +one slash character) in place of the hostname and port. .It Cm RequestTTY Specifies whether to request a pseudo-tty for the session. The argument may be one of:
enable forwarding to remote named sockets in ssh
I cannot forward to a socket on the remote host (No forward host name.). Example: ssh -L 12345:/tmp/sock Index: channels.c === RCS file: /cvs/src/usr.bin/ssh/channels.c,v retrieving revision 1.336 diff -u -p -r1.336 channels.c --- channels.c 15 Jul 2014 15:54:14 - 1.336 +++ channels.c 8 Aug 2014 20:31:29 - @@ -2771,13 +2770,18 @@ channel_setup_fwd_listener_tcpip(int typ fwd-listen_host : fwd-connect_host; is_client = (type == SSH_CHANNEL_PORT_LISTENER); - if (host == NULL) { - error(No forward host name.); - return 0; - } - if (strlen(host) = NI_MAXHOST) { - error(Forward host name too long.); - return 0; + if (type == SSH_CHANNEL_PORT_LISTENER + fwd-connect_path) + host = fwd-connect_path; + else { + if (host == NULL) { + error(No forward host name.); + return 0; + } + if (strlen(host) = NI_MAXHOST) { + error(Forward host name too long.); + return 0; + } } /* Determine the bind address, cf. channel_fwd_bind_addr() comment */
Re: sort(1) updates
On Wed, Jul 02, 2014 at 12:45:04PM -0400, Jared Yanovich wrote: Index: fsort.c If this patch is accepted it should include the NetBSD copyright I forgot to include. There's more to be done here, such as: $ { echo 0;\ echo 0.01; \ } | sort -n Alternatively we could just import the FreeBSD sort(1) rewrite from 2012.
Re: sort(1) updates
On Wed, Jul 02, 2014 at 12:37:53PM +0200, Otto Moerbeek wrote: On Tue, Jul 01, 2014 at 03:56:39PM -0400, Jared Yanovich wrote: This works better indeed. But is initing the int member only safe? If sizeof(top) sizeof(names), only init some bits of the pointer. To be safe, we can switch to memset. But upon a cursory look, names is only used via that path when binno=-1, which is not the case with tfiles.
Re: sort(1) updates
On Wed, Jul 02, 2014 at 04:37:05PM +0200, Otto Moerbeek wrote: Op 2 jul. 2014 om 15:03 heeft Jared Yanovich slovic...@gmail.com het volgende geschreven: On Wed, Jul 02, 2014 at 12:37:53PM +0200, Otto Moerbeek wrote: On Tue, Jul 01, 2014 at 03:56:39PM -0400, Jared Yanovich wrote: This works better indeed. But is initing the int member only safe? If sizeof(top) sizeof(names), only init some bits of the pointer. To be safe, we can switch to memset. But upon a cursory look, names is only used via that path when binno=-1, which is not the case with tfiles. We could also swap the union members, so that the biggest comes first. True but memset just future proofs any kind of changes down the road... Just completed 'make build' on amd64 with this. There may be some useful tests from GNU coreutils I can throw at it that I will look into later. Any other comments from anyone? Index: append.c === RCS file: /cvs/src/usr.bin/sort/append.c,v retrieving revision 1.10 diff -u -p -r1.10 append.c --- append.c27 Oct 2009 23:59:43 - 1.10 +++ append.c2 Jul 2014 16:43:33 - @@ -148,37 +148,3 @@ append(u_char **keylist, int nelem, int put(crec, fp); } } - -/* - * output the already sorted eol bin. - */ -void -rd_append(int binno, union f_handle infl0, int nfiles, FILE *outfp, -u_char *buffer, u_char *bufend) -{ - RECHEADER *rec; - - rec = (RECHEADER *) buffer; - if (!getnext(binno, infl0, nfiles, (RECHEADER *) buffer, bufend, 0)) { - putline(rec, outfp); - while (getnext(binno, infl0, nfiles, (RECHEADER *) buffer, - bufend, 0) == 0) { - if (!UNIQUE) - putline(rec, outfp); - } - } -} - -/* - * append plain text--used after sorting the biggest bin. - */ -void -concat(FILE *a, FILE *b) -{ -int nread; -char buffer[4096]; - - rewind(b); -while ((nread = fread(buffer, 1, 4096, b)) 0) -EWRITE(buffer, 1, nread, a); -} Index: extern.h === RCS file: /cvs/src/usr.bin/sort/extern.h,v retrieving revision 1.8 diff -u -p -r1.8 extern.h --- extern.h22 Dec 2009 19:47:02 - 1.8 +++ extern.h2 Jul 2014 16:43:33 - @@ -36,7 +36,6 @@ voidappend(u_char **, int, int, FILE *, void (*)(RECHEADER *, FILE *), struct field *); -voidconcat(FILE *, FILE *); length_t enterkey(RECHEADER *, DBT *, int, struct field *); voidfixit(int *, char **); voidfldreset(struct field *); @@ -44,11 +43,9 @@ FILE *ftmp(void); voidfmerge(int, union f_handle, int, int (*)(int, union f_handle, int, RECHEADER *, u_char *, struct field *), FILE *, void (*)(RECHEADER *, FILE *), struct field *); -voidfsort(int, int, union f_handle, int, FILE *, struct field *); +voidfsort(union f_handle, int, FILE *, struct field *); int geteasy(int, union f_handle, int, RECHEADER *, u_char *, struct field *); -int getnext(int, union f_handle, - int, RECHEADER *, u_char *, struct field *); int makekey(int, union f_handle, int, RECHEADER *, u_char *, struct field *); int makeline(int, union f_handle, @@ -57,7 +54,6 @@ void merge(int, int, int (*)(int, union f_handle, int, RECHEADER *, u_char *, struct field *), FILE *, void (*)(RECHEADER *, FILE *), struct field *); voidnum_init(void); -voidonepass(u_char **, int, long, long *, u_char *, FILE *); int optval(int, int); voidorder(union f_handle, int (*)(int, union f_handle, int, RECHEADER *, u_char *, struct field *), @@ -65,6 +61,5 @@ void order(union f_handle, int c_warn); voidputline(RECHEADER *, FILE *); voidputrec(RECHEADER *, FILE *); -voidrd_append(int, union f_handle, int, FILE *, u_char *, u_char *); int setfield(char *, struct field *, int); voidsettables(int); Index: files.c === RCS file: /cvs/src/usr.bin/sort/files.c,v retrieving revision 1.13 diff -u -p -r1.13 files.c --- files.c 27 Oct 2009 23:59:43 - 1.13 +++ files.c 2 Jul 2014 16:43:33 - @@ -40,73 +40,6 @@ static int seq(FILE *, DBT *, DBT *); /* - * this is the subroutine for file management for fsort(). - * It keeps the buffers for all temporary files. - */ -int -getnext(int binno, union f_handle infl0, int nfiles, RECHEADER *pos, u_char *end, -struct field *dummy) -{ - int i; - u_char *hp; - static size_t nleft = 0; - static int cnt = 0, flag = -1; - static u_char maxb = 0; - static FILE *fp; - - if (nleft == 0) { - if (binno 0) /* reset files. */ { - for (i = 0; i nfiles
Re: sort(1) updates
On Mon, Jun 30, 2014 at 11:53:04AM +0200, Otto Moerbeek wrote: This indeed solves some problems, but I have a test file on which it cores. Patch relative to the original diff I posted. diff -ru sort.new/fsort.c sort.new2/fsort.c --- sort.new/fsort.cTue Jul 1 15:54:45 2014 +++ sort.new2/fsort.c Tue Jul 1 15:55:15 2014 @@ -62,7 +62,7 @@ static size_t bufsize; int ntfiles, mfct = 0; int c, nelem; - union f_handle tfiles, mstart = { MAXFCT - MERGE_FNUM }; + union f_handle tfiles = { 0 }, mstart = { MAXFCT - MERGE_FNUM }; int (*get)(int, union f_handle, int, RECHEADER *, u_char *, struct field *); RECHEADER *crec;
sort(1) updates
Hi, sort(1) does some funky things and isn't hard to break: $ perl -e 'print \nx117000,x\n' | sort | sort -c This patch contains a few changes from NetBSD to correct the behavior regarding ordering of appending bins to output in certain circumstances which helps pass more of our own regress tests and improves performance (e.g. regress suite runtime is 40% with new code compared to old/current code on my box). The new code is also much easier to understand.. NetBSD logs: msort.c -r 1.9 merge(): use array of buffers instead of one big buffer for all records, and enlarge them as necessary to read records from merged files; the buffers are allocated once per program run, so there shouldn't be any performance difference This makes sort(1) pass also regression 40B and should make it fully arbitrary long record capable. XXX the buffer array could probably be freed on end of fmerge() to save memory fsort.c -r 1.37 The code that attempted to sort large files by sorting each chunk by the first key byte and writing to a temp file, then sorting the records from each temp file that had the same first key byte (and repeating for upto 4 key bytes) was a nice idea, but completely doomed to failure. Eg PR/9308 where a 70MB file has all but one record the same and short keys. Not only does the code not work, it is rather guaranteed to be slow. Instead always use a merge sort for fully sorted chunk of records (each temporary file contains one lot of sorted records). The -H option already did this, so just rip out all the code and variables that can't be used when -H was specified. Index: append.c === RCS file: /cvs/src/usr.bin/sort/append.c,v retrieving revision 1.10 diff -u -p -r1.10 append.c --- append.c27 Oct 2009 23:59:43 - 1.10 +++ append.c29 Jun 2014 22:17:16 - @@ -148,37 +148,3 @@ append(u_char **keylist, int nelem, int put(crec, fp); } } - -/* - * output the already sorted eol bin. - */ -void -rd_append(int binno, union f_handle infl0, int nfiles, FILE *outfp, -u_char *buffer, u_char *bufend) -{ - RECHEADER *rec; - - rec = (RECHEADER *) buffer; - if (!getnext(binno, infl0, nfiles, (RECHEADER *) buffer, bufend, 0)) { - putline(rec, outfp); - while (getnext(binno, infl0, nfiles, (RECHEADER *) buffer, - bufend, 0) == 0) { - if (!UNIQUE) - putline(rec, outfp); - } - } -} - -/* - * append plain text--used after sorting the biggest bin. - */ -void -concat(FILE *a, FILE *b) -{ -int nread; -char buffer[4096]; - - rewind(b); -while ((nread = fread(buffer, 1, 4096, b)) 0) -EWRITE(buffer, 1, nread, a); -} Index: extern.h === RCS file: /cvs/src/usr.bin/sort/extern.h,v retrieving revision 1.8 diff -u -p -r1.8 extern.h --- extern.h22 Dec 2009 19:47:02 - 1.8 +++ extern.h29 Jun 2014 22:17:16 - @@ -36,7 +36,6 @@ voidappend(u_char **, int, int, FILE *, void (*)(RECHEADER *, FILE *), struct field *); -voidconcat(FILE *, FILE *); length_t enterkey(RECHEADER *, DBT *, int, struct field *); voidfixit(int *, char **); voidfldreset(struct field *); @@ -44,11 +43,9 @@ FILE *ftmp(void); voidfmerge(int, union f_handle, int, int (*)(int, union f_handle, int, RECHEADER *, u_char *, struct field *), FILE *, void (*)(RECHEADER *, FILE *), struct field *); -voidfsort(int, int, union f_handle, int, FILE *, struct field *); +voidfsort(union f_handle, int, FILE *, struct field *); int geteasy(int, union f_handle, int, RECHEADER *, u_char *, struct field *); -int getnext(int, union f_handle, - int, RECHEADER *, u_char *, struct field *); int makekey(int, union f_handle, int, RECHEADER *, u_char *, struct field *); int makeline(int, union f_handle, @@ -57,7 +54,6 @@ void merge(int, int, int (*)(int, union f_handle, int, RECHEADER *, u_char *, struct field *), FILE *, void (*)(RECHEADER *, FILE *), struct field *); voidnum_init(void); -voidonepass(u_char **, int, long, long *, u_char *, FILE *); int optval(int, int); voidorder(union f_handle, int (*)(int, union f_handle, int, RECHEADER *, u_char *, struct field *), @@ -65,6 +61,5 @@ void order(union f_handle, int c_warn); voidputline(RECHEADER *, FILE *); voidputrec(RECHEADER *, FILE *); -voidrd_append(int, union f_handle, int, FILE *, u_char *, u_char *); int setfield(char *, struct field *, int); voidsettables(int); Index: files.c
ksh file completion with quotes
Hi, This patch adds some intelligence to emacs mode filename completion when dealing with quotes in ksh. Example: $ ls '/booTAB $ ls 'boot point becomes: $ ls 'boot' point Index: emacs.c === RCS file: /cvs/src/bin/ksh/emacs.c,v retrieving revision 1.48 diff -u -p -r1.48 emacs.c --- emacs.c 17 Dec 2013 16:37:05 - 1.48 +++ emacs.c 23 Jun 2014 15:00:41 - @@ -1799,12 +1799,31 @@ do_complete(int flags, /* XCF_{COMMAND,F nlen = x_longest_prefix(nwords, words); /* complete */ if (nwords == 1 || nlen olen) { + int isdir; + x_goto(xbuf + start); x_delete(olen, false); x_escape(words[0], nlen, x_emacs_putbuf); x_adjust(); completed = 1; + + isdir = words[0][nlen - 1] == '/'; + + /* add matching quote if we began with one */ + if (start 0 xbuf[start - 1] == '\'') { + if (xbuf[start + nlen] != '\'' !isdir) + x_ins('); + if (!isdir) + x_mv_forw(0); + } + if (start 0 xbuf[start - 1] == '') { + if (xbuf[start + nlen] != '' !isdir) + x_ins(\); + if (!isdir) + x_mv_forw(0); + } } + /* add space if single non-dir match */ if (nwords == 1 words[0][nlen - 1] != '/') { x_ins(space); pgpqTFCCq500X.pgp Description: PGP signature
getdents(2) corrections
Perhaps 'basep' was from an earlier proposed getdents interface but I'm not sure what it references now... Index: getdents.2 === RCS file: /cvs/src/lib/libc/sys/getdents.2,v retrieving revision 1.1 diff -u -p -r1.1 getdents.2 --- getdents.2 7 Oct 2013 01:50:26 - 1.1 +++ getdents.2 29 Nov 2013 22:15:58 - @@ -126,19 +126,13 @@ The actual number of bytes transferred i The current position pointer associated with .Fa fd is set to point to the next block of entries. -The pointer may not advance by the number of bytes returned by -.Fn getdents . -.Pp -.Fn getdents -writes the position of the block read into the location pointed to by -.Fa basep . -Alternatively, the current position pointer may be set and retrieved by -.Xr lseek 2 . -The current position pointer should only be set to a value returned by +This position can be set or retrieved by +.Xr lseek 2 +but should only ever be set to a value previously returned by .Xr lseek 2 , -a value returned in the location pointed to by -.Fa basep , or zero. +The pointer may not advance by the number of bytes returned by +.Fn getdents . .Sh RETURN VALUES If successful, the number of bytes actually transferred is returned. A value of zero is returned when @@ -154,10 +148,7 @@ will fail if: .Fa fd is not a valid file descriptor open for reading. .It Bq Er EFAULT -Either .Fa buf -or -.Fa basep points outside the allocated address space. .It Bq Er EINVAL The file referenced by @@ -174,6 +165,7 @@ error occurred while reading from or wri .Sh SEE ALSO .Xr lseek 2 , .Xr open 2 , +.Xr directory 3 , .Xr opendir 3 , .Xr dirent 5 .Sh STANDARDS pgp1ug3Wn2OO8.pgp Description: PGP signature