1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-10 00:31:07 +02:00

12436: Doc/Zsh/invoke.yo, Src/init.c: Make -b behave like

the csh -b, permitting more options to be stacked after it and
take effect.  Make -b take effect depending on SH_OPTION_LETTERS,
consistent with all the other single-letter options, rather than
having a clashing check of emulation type.
This commit is contained in:
Andrew Main 2000-07-30 19:18:13 +00:00
parent 9743c19d61
commit 84b04a8728
3 changed files with 23 additions and 12 deletions

View file

@ -1,3 +1,11 @@
2000-07-30 Andrew Main <zefram@zsh.org>
* 12436: Doc/Zsh/invoke.yo, Src/init.c: Make -b behave like
the csh -b, permitting more options to be stacked after it and
take effect. Make -b take effect depending on SH_OPTION_LETTERS,
consistent with all the other single-letter options, rather than
having a clashing check of emulation type.
2000-07-30 Andrew Main <zefram@zsh.org> 2000-07-30 Andrew Main <zefram@zsh.org>
* 12434: Doc/Zsh/invoke.yo, Src/init.c, Src/options.c, Src/zsh.h, * 12434: Doc/Zsh/invoke.yo, Src/init.c, Src/options.c, Src/zsh.h,

View file

@ -72,8 +72,11 @@ with preceding options (so `tt(-x-)' is equivalent to `tt(-x --)'). Options
are not permitted to be stacked after `tt(--)' (so `tt(-x-f)' is an error), are not permitted to be stacked after `tt(--)' (so `tt(-x-f)' is an error),
but note the GNU-style option form discussed above, where `tt(--shwordsplit)' but note the GNU-style option form discussed above, where `tt(--shwordsplit)'
is permitted and does not end option processing. is permitted and does not end option processing.
Except when emulating sh or ksh, the option `tt(-b)' is treated the same way
as `tt(--)' for the purpose of ending option processing. Except when the bf(sh)/bf(ksh) emulation single-letter options are in effect,
the option `tt(-b)' (or `tt(PLUS()b)') ends option processing.
`tt(-b)' is like `tt(--)', except that further single-letter options can be
stacked after the `tt(-b)' and will take effect as normal.
startmenu() startmenu()
menu(Compatibility) menu(Compatibility)

View file

@ -186,10 +186,10 @@ static int restricted;
void void
parseargs(char **argv) parseargs(char **argv)
{ {
int optionbreak = 0;
char **x; char **x;
int action, optno; int action, optno;
LinkList paramlist; LinkList paramlist;
int bourne = (emulation == EMULATE_KSH || emulation == EMULATE_SH);
argzero = *argv++; argzero = *argv++;
SHIN = 0; SHIN = 0;
@ -206,17 +206,15 @@ parseargs(char **argv)
opts[SINGLECOMMAND] = 0; opts[SINGLECOMMAND] = 0;
/* loop through command line options (begins with "-" or "+") */ /* loop through command line options (begins with "-" or "+") */
while (*argv && (**argv == '-' || **argv == '+')) { while (!optionbreak && *argv && (**argv == '-' || **argv == '+')) {
char *args = *argv; char *args = *argv;
action = (**argv == '-'); action = (**argv == '-');
if (!argv[0][1]) if (!argv[0][1])
*argv = "--"; *argv = "--";
while (*++*argv) { while (*++*argv) {
/* The pseudo-option `--' signifies the end of options. * if (**argv == '-') {
* `-b' does too, csh-style, unless we're emulating a *
* Bourne style shell. */
if (**argv == '-' || (!bourne && **argv == 'b')) {
if(!argv[0][1]) { if(!argv[0][1]) {
/* The pseudo-option `--' signifies the end of options. */
argv++; argv++;
goto doneoptions; goto doneoptions;
} }
@ -240,7 +238,11 @@ parseargs(char **argv)
goto longoptions; goto longoptions;
} }
if (**argv == 'c') { /* -c command */ if (unset(SHOPTIONLETTERS) && **argv == 'b') {
/* -b ends options at the end of this argument */
optionbreak = 1;
} else if (**argv == 'c') {
/* -c command */
cmd = *argv; cmd = *argv;
opts[INTERACTIVE] &= 1; opts[INTERACTIVE] &= 1;
opts[SHINSTDIN] = 0; opts[SHINSTDIN] = 0;
@ -321,13 +323,11 @@ parseargs(char **argv)
static void static void
printhelp(void) printhelp(void)
{ {
int bourne = (emulation == EMULATE_KSH || emulation == EMULATE_SH);
printf("Usage: %s [<options>] [<argument> ...]\n", argzero); printf("Usage: %s [<options>] [<argument> ...]\n", argzero);
printf("\nSpecial options:\n"); printf("\nSpecial options:\n");
printf(" --help show this message, then exit\n"); printf(" --help show this message, then exit\n");
printf(" --version show zsh version number, then exit\n"); printf(" --version show zsh version number, then exit\n");
if(!bourne) if(unset(SHOPTIONLETTERS))
printf(" -b end option processing, like --\n"); printf(" -b end option processing, like --\n");
printf(" -c take first argument as a command to execute\n"); printf(" -c take first argument as a command to execute\n");
printf(" -o OPTION set an option by name (see below)\n"); printf(" -o OPTION set an option by name (see below)\n");