rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
* ~ == $home
@ 1992-11-12 23:25 Stefan Axelsson
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Axelsson @ 1992-11-12 23:25 UTC (permalink / raw)
  To: The rc mailing list

Hmm, I missed the beginning of this thread, but I've avoided missing ~
== home by using cdpath, and the variable expansion feature of
editline.

1) Our usernames are very regular (d7stfax, aso) and thus are well suited
for inclusion in the cdpath variable. e.g:

cdpath=(. /users/dtek /users/dtek/d82 /users/dtek/d83 /users/dtek/d84 \
        /users/dtek/d85 /users/dtek/d86  /users/dtek/d87 /users/dtek/d88 \
        /users/dtek/d89 /users/dtek/d90 /users/dtek/d91
	/users/dtek/d92) 

Thus I can say cd d7stfax, and end up in: /users/dtek/d87/d7stfax.
Of course this solution doesn't cover all contingencies like ~d7stfax
would, but in practice I have had no problem with it.

2) Now there`s the annoying fact that you cannot use filename
completion to complete say; $h/bin/whateve. If you have editline
compiled in you can set '_H_' for instance to;
/users/dtek/d87/d7stfax/, and improve the situation.

Since I have a keyboard with a 'meta' shift key, I press M-Shift-h and
can use filename completion from there on.  OK, that's three
simultanous keys, but I have no problem with that.  Your command line
can get quite long though. As in 1) above this isn't perfect, but it
works like a charm for me.

These solutions may not, for various reasons, be right for you, but
then again everybodys mileage may vary.

Regards,
-- 
Stefan Axelsson,			Chalmers University of Technology,
d7stfax@dtek.chalmers.se		Sweden


^ permalink raw reply	[flat|nested] 2+ messages in thread

* ~ == $home
@ 1992-11-10 10:13 Brendan Kehoe
  0 siblings, 0 replies; 2+ messages in thread
From: Brendan Kehoe @ 1992-11-10 10:13 UTC (permalink / raw)
  To: rc mailing list; +Cc: brendan


Here's my first crack at making a tilde be used as an alternative to
$home (or $h).  (Well, it's actually my second--the first was an
addition to the grammar, doing `foo~bar' convinced me to forget
continuing to use that.)

This doesn't support ~user, but can with a little more hacking (I'm
too tired right now).  A ~ by itself at the beginning of the line
still works as the twiddle operator.

Just to make life complete, gcc 2.3.1 miscompiles footobar.c (list2array)
when optimization isn't being used.  (I'll be looking at that before I
do ~user.)

Brendan

*** glob.c.~1~	Mon Feb 17 14:45:24 1992
--- glob.c	Tue Nov 10 02:08:26 1992
*************** static List *doglob(char *w, char *m) {
*** 194,198 ****
  	   zero) since doglob gets called iff there's a metacharacter to be matched
  	*/
! 	if (*s == '\0') {
  		matched = dmatch(".", dir, metadir);
  		goto end;
--- 195,199 ----
  	   zero) since doglob gets called iff there's a metacharacter to be matched
  	*/
! 	if (*s == '\0' && *w != '~') {
  		matched = dmatch(".", dir, metadir);
  		goto end;
*************** static List *doglob(char *w, char *m) {
*** 203,206 ****
--- 204,216 ----
  		firstdir.n = NULL;
  		matched = &firstdir;
+ 	} else if (*w == '~') {
+ 		firstdir.w = varlookup("home")->w;
+ 		firstdir.n = NULL;
+ 		matched = &firstdir;
+ 		if (*s == '\0') {
+ 			firstdir.m = NULL;
+ 			goto end;
+ 		}
+ 		firstdir.m = metadir;
  	} else {
  		/*
*** lex.c.~1~	Tue Mar 31 08:40:20 1992
--- lex.c	Tue Nov 10 02:04:25 1992
***************
*** 38,42 ****
  	1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0,
  	1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0,
! 	1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0,
  	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
--- 38,42 ----
  	1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0,
  	1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0,
! 	1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, /* ~ */ 0, 0,
  	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
*************** top:	while ((c = gchar()) == ' ' || c ==
*** 98,104 ****
  		w = RW;
  		i = 0;
  	read:	do {
  			buf[i++] = c;
! 			if (c == '?' || c == '[' || c == '*')
  				saw_meta = TRUE;
  			if (i >= bufsize)
--- 98,111 ----
  		w = RW;
  		i = 0;
+ 		if (c == '~') {
+ 			c = gchar();
+ 			ugchar(c);
+ 			if (c == ' ' || c == '\t')
+ 				return TWIDDLE;
+ 			c = '~';
+ 		}
  	read:	do {
  			buf[i++] = c;
! 			if (c == '?' || c == '[' || c == '*' || c == '~')
  				saw_meta = TRUE;
  			if (i >= bufsize)

--
Brendan Kehoe                                               brendan@cygnus.com
Cygnus Support, Palo Alto, CA                                  +1 415 322 3811
                                                             His name's Avery!


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1992-11-12 23:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1992-11-12 23:25 ~ == $home Stefan Axelsson
  -- strict thread matches above, loose matches on Subject: below --
1992-11-10 10:13 Brendan Kehoe

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).