This file is getopts.def, from which is created getopts.c.
It implements the builtin "getopts" in Bash.
-Copyright (C) 1987-2004 Free Software Foundation, Inc.
+Copyright (C) 1987-2015 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
#endif
#include "../bashansi.h"
+#include "../bashintl.h"
#include "../shell.h"
#include "common.h"
extern char *this_command_name;
+static int getopts_unbind_variable __P((char *));
static int getopts_bind_variable __P((char *, char *));
static int dogetopts __P((int, char **));
sh_badopt = 0;
}
+static int
+getopts_unbind_variable (name)
+ char *name;
+{
+#if 0
+ return (unbind_variable (name));
+#else
+ return (unbind_variable_noref (name));
+#endif
+}
+
static int
getopts_bind_variable (name, value)
char *name, *value;
if (ret == G_EOF)
{
- unbind_variable ("OPTARG");
+ getopts_unbind_variable ("OPTARG");
getopts_bind_variable (name, "?");
return (EXECUTION_FAILURE);
}
bind_variable ("OPTARG", strval, 0);
}
else
- unbind_variable ("OPTARG");
+ getopts_unbind_variable ("OPTARG");
return (ret);
}
else
{
ret = getopts_bind_variable (name, "?");
- unbind_variable ("OPTARG");
+ getopts_unbind_variable ("OPTARG");
}
return (ret);
}
}
reset_internal_getopt ();
- if (internal_getopt (list, "") != -1)
+ if ((ret = internal_getopt (list, "")) != -1)
{
- builtin_usage ();
+ if (ret == GETOPT_HELP)
+ builtin_help ();
+ else
+ builtin_usage ();
return (EX_USAGE);
}
list = loptend;