Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: cshjunkieparen bothers me (and always has)



On Jun 30, 12:19am, Bart Schaefer wrote:
} Subject: cshjunkieparen bothers me (and always has)
}
} I'm having a really hard time figuring out why zsh can't simply support the
} `if ( ... ) { ... }' and `if [[ ... ]] { ... }' syntax all the time, and
} always have `( ... )' mean a subshell even with that syntax; and then get
} rid of the cshjunkieparen option.
} 
} If we really wanted a cshjunkieparen that meant something useful, it would
} mean that the parens were interpreted as [[ ... ]] like so:
} 
} 	if ( $TERM == xterm ) then
} 	    ...
} 	fi
} 
} I certainly wouldn't object to that -- though you'd probably have to call
} the option `cshjunkietests' now because cshjunkieparen is tainted.
} 
} I'm not suggesting that cshjunkietests be added to 3.0.0.  However, I *AM*
} suggesting that cshjunkieparen be removed in favor of always supporting
} the associated syntax.

Here's a patch that does just that -- removes cshjunkieparen, leaving the
associated syntax supported.  This patch also includes, but comments out,
the code to implement cshjunkietests.

No man page patch here, as I'm offering this only for consideration at
this point.

diff -c zsh-3.0-pre1/Src/globals.h zsh-3.0-pre1-work/Src/globals.h
*** zsh-3.0-pre1/Src/globals.h	Fri Jun 28 06:43:49 1996
--- zsh-3.0-pre1-work/Src/globals.h	Mon Jul  1 12:02:40 1996
***************
*** 648,654 ****
      {"correctall", 		'O', 0,   0},
      {"cshjunkiehistory", 	0,   0,   OPT_EMULATE|OPT_CSH},
      {"cshjunkieloops", 		0,   0,   OPT_EMULATE|OPT_CSH},
!     {"cshjunkieparen", 		0,   0,   OPT_EMULATE|OPT_CSH},
      {"cshjunkiequotes", 	0,   0,   OPT_EMULATE|OPT_CSH},
      {"cshnullglob", 		0,   0,   OPT_EMULATE|OPT_CSH},
      {"errexit", 		'e', 'e', 0},
--- 648,654 ----
      {"correctall", 		'O', 0,   0},
      {"cshjunkiehistory", 	0,   0,   OPT_EMULATE|OPT_CSH},
      {"cshjunkieloops", 		0,   0,   OPT_EMULATE|OPT_CSH},
! /*  {"cshjunkietests", 		0,   0,   OPT_EMULATE|OPT_CSH}, */
      {"cshjunkiequotes", 	0,   0,   OPT_EMULATE|OPT_CSH},
      {"cshnullglob", 		0,   0,   OPT_EMULATE|OPT_CSH},
      {"errexit", 		'e', 'e', 0},
diff -c zsh-3.0-pre1/Src/parse.c zsh-3.0-pre1-work/Src/parse.c
*** zsh-3.0-pre1/Src/parse.c	Fri Jun 28 06:43:50 1996
--- zsh-3.0-pre1-work/Src/parse.c	Mon Jul  1 12:03:32 1996
***************
*** 412,418 ****
  	c->args = par_wordlist();
  	if (tok != SEPER)
  	    YYERRORV;
!     } else if (tok == INPAR && (csh || isset(CSHJUNKIEPAREN))) {
  	f->inflag = 1;
  	incmdpos = 0;
  	yylex();
--- 412,418 ----
  	c->args = par_wordlist();
  	if (tok != SEPER)
  	    YYERRORV;
!     } else if (tok == INPAR) {
  	f->inflag = 1;
  	incmdpos = 0;
  	yylex();
***************
*** 599,620 ****
  	    cmdpop();
  	    YYERRORV;
  	}
! 	if (tok == INPAR && isset(CSHJUNKIEPAREN)) {
! 	    yylex();
! 	    l = par_list();
! 	    if (tok != OUTPAR) {
! 		cmdpop();
! 		YYERRORV;
! 	    }
! 	    addlinknode(ifsl, l);
! 	    ni++;
! 	    incmdpos = 1;
! 	    yylex();
! 	} else {
! 	    addlinknode(ifsl, par_list());
! 	    ni++;
! 	    incmdpos = 1;
! 	}
  	while (tok == SEPER)
  	    yylex();
  	xtok = FI;
--- 599,611 ----
  	    cmdpop();
  	    YYERRORV;
  	}
! /*
! 	if (tok == INPAR && isset(CSHJUNKIETESTS))
! 	    tok = DINBRACK;
! */
! 	addlinknode(ifsl, par_list());
! 	ni++;
! 	incmdpos = 1;
  	while (tok == SEPER)
  	    yylex();
  	xtok = FI;
***************
*** 627,633 ****
  	    nt++;
  	    incmdpos = 1;
  	    cmdpop();
! 	} else if (isset(CSHJUNKIEPAREN)) {
  	    if (tok == INBRACE) {
  		cmdpop();
  		cmdpush(nc);
--- 618,624 ----
  	    nt++;
  	    incmdpos = 1;
  	    cmdpop();
! 	} else {
  	    if (tok == INBRACE) {
  		cmdpop();
  		cmdpush(nc);
***************
*** 655,663 ****
  		incmdpos = 1;
  		break;
  	    }
- 	} else {
- 	    cmdpop();
- 	    YYERRORV;
  	}
      }
      cmdpop();
--- 646,651 ----
***************
*** 665,690 ****
  	cmdpush(CS_ELSE);
  	while (tok == SEPER)
  	    yylex();
! 	if (isset(CSHJUNKIEPAREN) && tok == INBRACE) {
! 	    yylex();
! 	    l = par_list();
! 	    if (tok != OUTBRACE) {
! 		cmdpop();
! 		YYERRORV;
! 	    }
! 	    addlinknode(thensl, l);
! 	    nt++;
! 	    yylex();
! 	} else {
! 	    l = par_list();
! 	    if (tok != FI) {
! 		cmdpop();
! 		YYERRORV;
! 	    }
! 	    addlinknode(thensl, l);
! 	    nt++;
! 	    yylex();
  	}
  	cmdpop();
      }
      i = (struct ifcmd *)make_ifcmd();
--- 653,666 ----
  	cmdpush(CS_ELSE);
  	while (tok == SEPER)
  	    yylex();
! 	l = par_list();
! 	if (tok != FI) {
! 	    cmdpop();
! 	    YYERRORV;
  	}
+ 	addlinknode(thensl, l);
+ 	nt++;
+ 	yylex();
  	cmdpop();
      }
      i = (struct ifcmd *)make_ifcmd();
***************
*** 718,732 ****
      w = c->u.whilecmd = (struct whilecmd *)make_whilecmd();
      w->cond = (tok == UNTIL);
      yylex();
!     if (tok == INPAR && isset(CSHJUNKIEPAREN)) {
! 	yylex();
! 	w->cont = par_list();
! 	if (tok != OUTPAR)
! 	    YYERRORV;
! 	yylex();
!     } else {
! 	w->cont = par_list();
!     }
      incmdpos = 1;
      while (tok == SEPER)
  	yylex();
--- 694,704 ----
      w = c->u.whilecmd = (struct whilecmd *)make_whilecmd();
      w->cond = (tok == UNTIL);
      yylex();
! /*
!     if (tok == INPAR && isset(CSHJUNKIETESTS))
! 	tok = DINBRACK;
! */
!     w->cont = par_list();
      incmdpos = 1;
      while (tok == SEPER)
  	yylex();
***************
*** 863,868 ****
--- 835,844 ----
      incmdpos = 0;
      yylex();
      c->u.cond = par_cond();
+ /*
+     if (isset(CSHJUNKIETESTS) && tok == OUTPAR)
+ 	tok = DOUTBRACK;
+ */
      if (tok != DOUTBRACK)
  	YYERRORV;
      incond = 0;
diff -c zsh-3.0-pre1/Src/zsh.h zsh-3.0-pre1-work/Src/zsh.h
*** zsh-3.0-pre1/Src/zsh.h	Fri Jun 28 06:43:52 1996
--- zsh-3.0-pre1-work/Src/zsh.h	Mon Jul  1 12:03:15 1996
***************
*** 1037,1043 ****
      CORRECTALL,
      CSHJUNKIEHISTORY,
      CSHJUNKIELOOPS,
!     CSHJUNKIEPAREN,
      CSHJUNKIEQUOTES,
      CSHNULLGLOB,
      ERREXIT,
--- 1037,1043 ----
      CORRECTALL,
      CSHJUNKIEHISTORY,
      CSHJUNKIELOOPS,
! /*  CSHJUNKIETESTS, */
      CSHJUNKIEQUOTES,
      CSHNULLGLOB,
      ERREXIT,

-- 
Bart Schaefer                             Brass Lantern Enterprises
http://www.well.com/user/barts            http://www.nbn.com/people/lantern

New male in /home/schaefer:
>N  2 Justin William Schaefer  Sat May 11 03:43  53/4040  "Happy Birthday"




Messages sorted by: Reverse Date, Date, Thread, Author